Skip to content

Commit

Permalink
[FIX] Evaluation: Remove old spreaded cells from spread relations
Browse files Browse the repository at this point in the history
Currently, the spread relations of a spreaded formula are not invalidated.
The evaluated value of the relation is currently properly invalidated
so it's not posing any problem during the evaluation/display
phase but some features rely specifically on the spreading relation
(e.g. the pivot cells highlighting in the top bar) and the current
situation leads to false positives (see attached test).

closes #5275

Task: 4342240
X-original-commit: 8d4accf
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
rrahir committed Nov 28, 2024
1 parent fbe6f96 commit 35ca29c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/evaluation/evaluation_formula_array.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { arg, functionRegistry } from "../../src/functions";
import { toScalar } from "../../src/functions/helper_matrices";
import { toMatrix, toNumber } from "../../src/functions/helpers";
import { toZone } from "../../src/helpers";
import { toCartesian, toZone } from "../../src/helpers";
import { Model } from "../../src/model";
import { DEFAULT_LOCALE, ErrorCell, UID } from "../../src/types";
import {
Expand Down Expand Up @@ -709,6 +709,21 @@ describe("evaluate formulas that return an array", () => {
expect(c).toEqual(2);
});

test("Cells that no longer depend on the array formula are removed from the spreading dependencies", () => {
setCellContent(model, "A1", "=TRANSPOSE(A3:A4)");
setCellContent(model, "A3", "3");
setCellContent(model, "A4", "4");
expect(getEvaluatedCell(model, "B1").value).toEqual(4);
const sheetId = model.getters.getActiveSheetId();
expect(model.getters.getCorrespondingFormulaCell({ sheetId, ...toCartesian("B1") })).toBe(
model.getters.getCorrespondingFormulaCell({ sheetId, ...toCartesian("A1") })
);
setCellContent(model, "A1", "=TRANSPOSE(A3)");
expect(
model.getters.getCorrespondingFormulaCell({ sheetId, ...toCartesian("B1") })
).toBeUndefined();
});

test("have collision when spread size zone change", () => {
setCellContent(model, "A1", "1");
setCellContent(model, "B1", "=MFILL(1,A1+1,42)");
Expand Down

0 comments on commit 35ca29c

Please sign in to comment.