mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +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.parsedMatches = [];
|
||||||
this.currentFound = 0;
|
this.currentFound = 0;
|
||||||
this.totalFound = 0;
|
this.totalFound = 0;
|
||||||
this.matches = (new RangeSetBuilder<Decoration>()).finish();
|
this.matches = RangeSet.empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
searchFor(searchTerm: string, matchCase: boolean, wholeWord: boolean) {
|
searchFor(searchTerm: string, matchCase: boolean, wholeWord: boolean) {
|
||||||
|
if (!searchTerm) {
|
||||||
|
this.matches = RangeSet.empty;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Escape the search term for use in RegExp
|
// Escape the search term for use in RegExp
|
||||||
const escapedTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
const escapedTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
const wordBoundary = wholeWord ? "\\b" : "";
|
const wordBoundary = wholeWord ? "\\b" : "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user