Fix infinite loop in autocompletion

In some cases, the token used for highlighting autocompletion gets to be
empty, resulting in an infinte loop. One such case is searching for `''`
(without the backticks).
This commit is contained in:
Elian Doran 2023-02-27 00:59:46 +02:00
parent a88582c610
commit 5820f874fc

View file

@ -334,6 +334,11 @@ function highlightSearchResults(searchResults, highlightedTokens) {
}
for (const token of highlightedTokens) {
if (!token) {
// Avoid empty tokens, which might cause an infinite loop.
continue;
}
for (const result of searchResults) {
// Reset token
const tokenRegex = new RegExp(utils.escapeRegExp(token), "gi");