mirror of
https://github.com/zadam/trilium.git
synced 2025-01-15 03:27:44 +08:00
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:
parent
a88582c610
commit
5820f874fc
1 changed files with 5 additions and 0 deletions
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue