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;
|
||||
}
|
||||
const [pos, prefix] = binarySearch(trie.children, remaining);
|
||||
if (prefix.length !== remaining.length) {
|
||||
return [];
|
||||
if (prefix.length === haveKey.length) {
|
||||
return __suggest(haveChildNode, path+haveKey, remaining.slice(haveKey.length), maxSuggestions)
|
||||
}
|
||||
const [haveKey, haveChildNode] = trie.children[pos];
|
||||
return __suggest(haveChildNode, path+haveKey, remaining.slice(haveKey.length), maxSuggestions);
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue