fix bug in Trie.suggest?
This commit is contained in:
parent
a166ebb0d7
commit
660512cc19
1 changed files with 3 additions and 4 deletions
|
|
@ -153,9 +153,8 @@ const __suggest = (trie, path, remaining, maxSuggestions) => {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
const [pos, prefix] = binarySearch(trie.children, remaining);
|
const [pos, prefix] = binarySearch(trie.children, remaining);
|
||||||
if (prefix.length !== remaining.length) {
|
if (prefix.length === haveKey.length) {
|
||||||
|
return __suggest(haveChildNode, path+haveKey, remaining.slice(haveKey.length), maxSuggestions)
|
||||||
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const [haveKey, haveChildNode] = trie.children[pos];
|
|
||||||
return __suggest(haveChildNode, path+haveKey, remaining.slice(haveKey.length), maxSuggestions);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue