mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01: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
@ -334,6 +334,11 @@ function highlightSearchResults(searchResults, highlightedTokens) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const token of highlightedTokens) {
|
for (const token of highlightedTokens) {
|
||||||
|
if (!token) {
|
||||||
|
// Avoid empty tokens, which might cause an infinite loop.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (const result of searchResults) {
|
for (const result of searchResults) {
|
||||||
// Reset token
|
// Reset token
|
||||||
const tokenRegex = new RegExp(utils.escapeRegExp(token), "gi");
|
const tokenRegex = new RegExp(utils.escapeRegExp(token), "gi");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user