(core) Fix autocomplete selection when options include emoji

Summary:
Searching for matching choices was using nativeCompare for a binary search,
while the list was sorted according to localeCompare. This was causing the
search to fail for some strings when the two orderings differ.

Test Plan: Tested manually

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3059
This commit is contained in:
Dmitry S 2021-10-04 18:52:03 -04:00
parent e1780e4f58
commit 43a62e7254

View File

@ -163,7 +163,7 @@ export class ACIndexImpl<Item extends ACItem> implements ACIndex<Item> {
*/ */
private _findOverlaps(searchWord: string, searchWordPos: number): Map<number, number> { private _findOverlaps(searchWord: string, searchWordPos: number): Map<number, number> {
const insertIndex = sortedIndex<{word: string}>(this._words, {word: searchWord}, const insertIndex = sortedIndex<{word: string}>(this._words, {word: searchWord},
(a, b) => nativeCompare(a.word, b.word)); (a, b) => localeCompare(a.word, b.word));
// Maps index of item to its score. // Maps index of item to its score.
const scored = new Map<number, number>(); const scored = new Map<number, number>();