Skip to content

Commit

Permalink
[FIX] Edition: filter invalid references from edition highlights
Browse files Browse the repository at this point in the history
closes #3383

Task: 3378775
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
  • Loading branch information
rrahir committed Jan 22, 2024
1 parent b3affc5 commit 6f766f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plugins/ui/edition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,10 @@ export class EditionPlugin extends UIPlugin {
*/
getReferencedRanges(): Range[] {
const editionSheetId = this.getters.getEditionSheet();
return this.currentTokens
const referenceRanges = this.currentTokens
.filter((token) => token.type === "REFERENCE")
.map((token) => this.getters.getRangeFromSheetXC(editionSheetId, token.value));
return referenceRanges.filter((range) => !range.invalidSheetName && !range.invalidXc);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/plugins/edition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,4 +812,13 @@ describe("edition", () => {
model.dispatch("CYCLE_EDITION_REFERENCES");
expect(model.getters.getCurrentContent()).toBe(`=${composerSheetName}!A1`);
});

test("Invalid references are filtered out from the highlights", () => {
const model = new Model({});
const fakeSheetName = "louloulou";
model.dispatch("START_EDITION", { text: `=${fakeSheetName}!A1+A2+ZZZZZZZZZ1000000` });
const highlights = model.getters.getComposerHighlights();
expect(highlights).toHaveLength(1);
expect(highlights[0].zone).toMatchObject(toZone("A2"));
});
});

0 comments on commit 6f766f2

Please sign in to comment.