diff --git a/src/plugins/ui_core_views/cell_evaluation/evaluator.ts b/src/plugins/ui_core_views/cell_evaluation/evaluator.ts index d79b08b06a..c3d4a5d879 100644 --- a/src/plugins/ui_core_views/cell_evaluation/evaluator.ts +++ b/src/plugins/ui_core_views/cell_evaluation/evaluator.ts @@ -259,6 +259,7 @@ export class Evaluator { return this.handleError(e, cell); } finally { this.cellsBeingComputed.delete(cellId); + this.nextPositionsToUpdate.delete(positionId); } } diff --git a/tests/evaluation/evaluation_formula_array.test.ts b/tests/evaluation/evaluation_formula_array.test.ts index 98c7e4f786..04d804075b 100644 --- a/tests/evaluation/evaluation_formula_array.test.ts +++ b/tests/evaluation/evaluation_formula_array.test.ts @@ -637,8 +637,8 @@ describe("evaluate formulas that return an array", () => { setCellContent(model, "C1", "=MFILL(2,1,B1+1)"); expect(getEvaluatedCell(model, "A1").value).toBe(31); expect(getEvaluatedCell(model, "B1").value).toBe(31); - expect(getEvaluatedCell(model, "C1").value).toBe(32); - expect(getEvaluatedCell(model, "D1").value).toBe(32); + expect(getEvaluatedCell(model, "C1").value).toBe(30); + expect(getEvaluatedCell(model, "D1").value).toBe(30); }); test("Spreaded formulas with range deps Do not invalidate themselves on evaluation", () => { @@ -665,6 +665,31 @@ describe("evaluate formulas that return an array", () => { expect(c).toEqual(3); }); + test("array formula depending on array formula result is evaluated once", () => { + const mockCompute = jest.fn().mockImplementation((values) => values); + + functionRegistry.add("RANGE_IDENTITY", { + description: "returns the input. Like transpose(transpose(range))", + args: [arg("range (range)", "")], + returns: ["RANGE"], + compute: mockCompute, + }); + new Model({ + sheets: [ + { + cells: { + A1: { content: "0" }, + A2: { content: "1" }, + B1: { content: "=RANGE_IDENTITY(A1:A2)" }, + C1: { content: "=RANGE_IDENTITY(B1:B2)" }, + D1: { content: "=RANGE_IDENTITY(C1:C2)" }, + }, + }, + ], + }); + expect(mockCompute).toHaveBeenCalledTimes(3); + }); + test("Spreaded formulas with range deps invalidate only once the dependencies of themselves", () => { let c = 0; functionRegistry.add("INCREMENTONEVAL", {