fix bug in trie

This commit is contained in:
Joeri Exelmans 2025-05-10 20:53:36 +02:00
parent fe6e86e1a4
commit 3b8548e9af
2 changed files with 13 additions and 0 deletions

View file

@ -183,6 +183,9 @@ const __suggest = (trie, path, remaining, maxSuggestions) => {
}
const [pos, prefix] = binarySearch(trie.children, remaining);
if (prefix.length === 0) {
return []; // nothing in common
}
if (pos < trie.children.length) {
const [haveKey, haveChildNode] = trie.children[pos];
return __suggest(haveChildNode, path+haveKey, remaining.slice(haveKey.length), maxSuggestions);