From 660512cc197b110637254c9376cace72a2bb6c5e Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Sat, 10 May 2025 19:37:38 +0200 Subject: [PATCH] fix bug in Trie.suggest? --- lib/util/trie.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/util/trie.js b/lib/util/trie.js index 2bdff26..a98f6b1 100644 --- a/lib/util/trie.js +++ b/lib/util/trie.js @@ -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 []; }