Skip to content

Commit

Permalink
[FIX] evaluation: evaluate new dependencies
Browse files Browse the repository at this point in the history
Commit 43f4fdd is wrong, the dependencies should be evaluated,
not the position.

closes #4183

Task: 0
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
  • Loading branch information
LucasLefevre committed May 7, 2024
1 parent 43f4fdd commit e374e17
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugins/ui_core_views/cell_evaluation/evaluator.ts
Expand Up @@ -91,7 +91,15 @@ export class Evaluator {

private addDependencies(position: CellPosition, dependencies: Range[]) {
this.formulaDependencies().addDependencies(position, dependencies);
this.computeAndSave(position);
for (const range of dependencies) {
const sheetId = range.sheetId;
const { left, bottom, right, top } = range.zone;
for (let col = left; col <= right; col++) {
for (let row = top; row <= bottom; row++) {
this.computeAndSave({ sheetId, col, row });
}
}
}
}

private updateCompilationParameters() {
Expand Down
17 changes: 17 additions & 0 deletions tests/functions/module_lookup.test.ts
Expand Up @@ -1567,6 +1567,23 @@ describe("INDIRECT formula", () => {
expect(grid.A4).toBe(6);
});

test("Dependencies are correctly evaluated", () => {
const model = new Model({
sheets: [
{
cells: {
A1: { content: '=INDIRECT("B1")' },
B1: { content: "hello" },
A2: { content: '=INDIRECT("B2")' },
B2: { content: "=1+1" },
},
},
],
});
expect(getCellContent(model, "A1")).toBe("hello");
expect(getCellContent(model, "A2")).toBe("2");
});

test("Reference to a cell and range of a different sheet (A1 notation)", () => {
const model = new Model();
const sheetId = model.getters.getActiveSheetId();
Expand Down

0 comments on commit e374e17

Please sign in to comment.