Skip to content

Commit

Permalink
[FIX] Find&Replace: always search cell content if searchFormula
Browse files Browse the repository at this point in the history
The current implementation of a search with the option `serachFormula`
will only look into the cell content if the cell is a valid formula cell
and not a cell which results in an error following its evaluation.

e.g.  A1: '=SUM("a")' is invalid thus the related cell is not a formula
cell but an error cell and will never be matched when looking for the
term "sum".

closes #4992

Task: 4175968
X-original-commit: ce6ad5c
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
rrahir committed Sep 17, 2024
1 parent e5e2be8 commit d73ba2a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/find_and_replace/find_and_replace_store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
getActivePosition,
getCell,
getCellContent,
getCellError,
getCellText,
} from "../test_helpers/getters_helpers";
import { makeStore } from "../test_helpers/stores";
Expand Down Expand Up @@ -591,6 +592,18 @@ describe("search options", () => {
expect(store.selectedMatchIndex).toBe(null);
});

test("Search in formula searches cell content of a cell in error", () => {
setCellContent(model, "A6", "=notASumifFunction(2)");
setCellContent(model, "A7", '=SUMIF("a")');
expect(getCellError(model, "A6")).toBeDefined();
expect(getCellError(model, "A7")).toBeDefined();
updateSearch(model, "sumif", { searchScope: "activeSheet", searchFormulas: true });
const matches = store.searchMatches;
expect(matches).toHaveLength(2);
expect(matches[0]).toStrictEqual({ sheetId: sheetId1, col: 0, row: 5 });
expect(matches[1]).toStrictEqual({ sheetId: sheetId1, col: 0, row: 6 });
});

test("Combine matching case / matching entire cell / search in formulas", () => {
updateSearch(model, "hell");
expect(store.selectedMatchIndex).toStrictEqual(0);
Expand Down

0 comments on commit d73ba2a

Please sign in to comment.