mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
fix(code/find): infinite loop when empty
This commit is contained in:
parent
07a751c677
commit
da6cb71c6a
@ -19,10 +19,15 @@ export class SearchHighlighter {
|
||||
this.parsedMatches = [];
|
||||
this.currentFound = 0;
|
||||
this.totalFound = 0;
|
||||
this.matches = (new RangeSetBuilder<Decoration>()).finish();
|
||||
this.matches = RangeSet.empty;
|
||||
}
|
||||
|
||||
searchFor(searchTerm: string, matchCase: boolean, wholeWord: boolean) {
|
||||
if (!searchTerm) {
|
||||
this.matches = RangeSet.empty;
|
||||
return;
|
||||
}
|
||||
|
||||
// Escape the search term for use in RegExp
|
||||
const escapedTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const wordBoundary = wholeWord ? "\\b" : "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user