Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Evaluation: Remove old spreaded cells from spread relations #5225

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/plugins/ui_core_views/cell_evaluation/evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export class Evaluator {
this.evaluatedCells.delete(child);
Copy link
Contributor

@hokolomopo hokolomopo Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in commit message "invalidated pso it's"

this.nextPositionsToUpdate.addMany(this.getCellsDependingOn([child]));
this.nextPositionsToUpdate.addMany(this.getArrayFormulasBlockedBy(child));
this.spreadingRelations.removeNode(child);
}
this.spreadingRelations.removeNode(positionId);
}
Expand Down
16 changes: 16 additions & 0 deletions tests/evaluation/evaluation_formula_array.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { arg, functionRegistry } from "../../src/functions";
import { toNumber } from "../../src/functions/helpers";
import { toCartesian } from "../../src/helpers";
import { Model } from "../../src/model";
import {
Arg,
Expand Down Expand Up @@ -747,6 +748,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("B1") })
);
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