Commit ed10ce5
fix(lookup): skip empty cells in approximate MATCH/lookup search (HF-223)
Excel and Google Sheets ignore genuinely empty cells (but not empty
strings) when computing the lower/upper bound for an approximate match.
HyperFormula instead landed on an empty cell during binary search and
returned #N/A (its EmptyValue Symbol never matched the key), or, in
descending mode, reported the wrong position.
findLastOccurrenceInOrderedRange now runs the ordered search over a
compacted list of non-empty cell indices and maps the result back to the
original index space, so empty cells keep their slots and the matched
non-empty cell's original 1-based position is reported unchanged. When
the range has no non-empty cells the function returns NOT_FOUND, so an
all-empty range yields #N/A for every direction/bound instead of falling
through to the offset-0 branches. The in-memory ordered path in
AdvancedFind.findNormalizedValue skips EmptyValue for the same reason.
Empty strings are unaffected (text is ranked above numbers, so they
still terminate a numeric run). Exact match (matchType 0) is untouched.
Shared by approximate MATCH(+/-1), sorted VLOOKUP/HLOOKUP, and
XLOOKUP(searchMode +/-2). Tests for the public test suite are tracked
separately in handsontable/hyperformula-tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 72205bd commit ed10ce5
3 files changed
Lines changed: 43 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
91 | 99 | | |
92 | 100 | | |
93 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
| |||
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
38 | 62 | | |
39 | 63 | | |
40 | 64 | | |
41 | 65 | | |
42 | | - | |
43 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
44 | 69 | | |
45 | 70 | | |
46 | 71 | | |
| |||
61 | 86 | | |
62 | 87 | | |
63 | 88 | | |
64 | | - | |
65 | | - | |
| 89 | + | |
| 90 | + | |
66 | 91 | | |
67 | 92 | | |
68 | 93 | | |
| |||
80 | 105 | | |
81 | 106 | | |
82 | 107 | | |
83 | | - | |
84 | | - | |
| 108 | + | |
| 109 | + | |
85 | 110 | | |
86 | 111 | | |
87 | 112 | | |
| |||
0 commit comments