diff --git a/src/plugins/core/cell.ts b/src/plugins/core/cell.ts index 19192e9c84..1f6437e785 100644 --- a/src/plugins/core/cell.ts +++ b/src/plugins/core/cell.ts @@ -344,6 +344,9 @@ export class CellPlugin extends CorePlugin implements CoreState { dependencies: Range[], useFixedReference: boolean = false ): string { + if (!dependencies.length) { + return concat(compiledFormula.tokens.map((token) => token.value)); + } let rangeIndex = 0; return concat( compiledFormula.tokens.map((token) => { diff --git a/tests/clipboard/clipboard_plugin.test.ts b/tests/clipboard/clipboard_plugin.test.ts index f1b74480c7..946d9a4554 100644 --- a/tests/clipboard/clipboard_plugin.test.ts +++ b/tests/clipboard/clipboard_plugin.test.ts @@ -1458,6 +1458,18 @@ describe("clipboard", () => { }); }); + test("can cut and paste an invalid formula", () => { + const model = new Model(); + setCellContent(model, "A1", "=(+)"); + setCellContent(model, "A2", "=C1{C2"); + cut(model, "A1:A2"); + paste(model, "C1"); + expect(getCellText(model, "C1")).toBe("=(+)"); + expect(getCellText(model, "C2")).toBe("=C1{C2"); + expect(getCellText(model, "A1")).toBe(""); + expect(getCellText(model, "A2")).toBe(""); + }); + test("cut/paste a formula with references does not update references in the formula", () => { const model = new Model(); setCellContent(model, "A1", "=SUM(C1:C2)");