@singapore-editor/find 0.2.12 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/search.js CHANGED
@@ -1,8 +1,13 @@
1
1
  import { codePointSizeAt, compareTextOffsetRanges, isWholeWordRange } from "@singapore-editor/core/document";
2
2
  // src/search.ts
3
3
  var FIND_MATCHES_LIMIT = 19999;
4
+ var FIND_SELECT_ALL_LIMIT = 1e4;
4
5
  var FIND_REPLACE_ALL_LIMIT = 1073741824;
5
6
  var FIND_WINDOW_UNITS = 65536;
7
+ var FIND_SYNC_THRESHOLD = 262144;
8
+ var FIND_VIEWPORT_SYNC_MAX_UNITS = 131072;
9
+ var FIND_VIEWPORT_FALLBACK_HALF_UNITS = 16384;
10
+ var REGEX_SLICE_CHECK_INTERVAL = 64;
6
11
  var LINE_SAFE_ESCAPES = /* @__PURE__ */ new Set([
7
12
  "d",
8
13
  "w",
@@ -43,26 +48,96 @@ function findMatches(source, query, ranges = null, captureMatches = false, limit
43
48
  }
44
49
  return matches;
45
50
  }
51
+ /** Null for a query that cannot be compiled, which is one that finds nothing. */
52
+ function findQueryPlan(query) {
53
+ return compileFindQuery(query)?.plan ?? null;
54
+ }
55
+ /** Total UTF-16 code units covered by the merged search ranges. */
56
+ function searchedRangesLength(source, ranges = null) {
57
+ let total = 0;
58
+ for (const range of searchRanges(source, ranges)) total += range.end - range.start;
59
+ return total;
60
+ }
46
61
  /**
47
- * Every match counted, none kept: a total costs no record per match.
62
+ * Splits line-local search ranges around a line-aligned visible viewport span.
48
63
  *
49
- * With `before`, only the matches starting in front of that offset, which is the
50
- * position of a match the listing stopped short of.
64
+ * Every line belongs to at most one of `prefixRanges`, `viewportRanges`, or
65
+ * `suffixRanges`, so scanning the viewport synchronously first and the
66
+ * remaining two regions in background slices visits every character at most
67
+ * once and produces matches identical to a single pass.
51
68
  */
52
- function countMatches(source, query, ranges = null, before = Number.POSITIVE_INFINITY) {
53
- const compiled = compileFindQuery(query);
54
- if (!compiled) return 0;
55
- let count = 0;
56
- const tally = (start) => {
57
- if (start >= before) return false;
58
- count += 1;
59
- return true;
69
+ function partitionViewportRanges(source, scopes, visibleRange, anchorOffset) {
70
+ const ranges = searchRanges(source, scopes);
71
+ if (source.length === 0) return {
72
+ viewportSpan: null,
73
+ viewportRanges: ranges,
74
+ prefixRanges: [],
75
+ suffixRanges: []
60
76
  };
61
- for (const range of searchRanges(source, ranges)) {
62
- if (range.start >= before) break;
63
- scanRange(source, compiled, range, false, tally);
77
+ const bounded = boundedPrioritySpan(source, visibleRange, anchorOffset);
78
+ const lineStartsView = source.lineStartsView;
79
+ let firstLine = lineStartsView.indexForOffset(bounded.start);
80
+ let lastLine = lineStartsView.indexForOffset(bounded.end);
81
+ let vpStart = lineStartsView.at(firstLine) ?? 0;
82
+ let vpEnd = lineEndAt(source, lastLine);
83
+ if (vpEnd - vpStart > 131072) {
84
+ const anchor = clampSourceOffset(source, anchorOffset);
85
+ const anchorLine = Math.min(lastLine, Math.max(firstLine, lineStartsView.indexForOffset(anchor)));
86
+ const anchorLineStart = lineStartsView.at(anchorLine) ?? 0;
87
+ const anchorLineEnd = lineEndAt(source, anchorLine);
88
+ if (anchorLineEnd - anchorLineStart > 131072) return {
89
+ viewportSpan: null,
90
+ viewportRanges: [],
91
+ prefixRanges: ranges,
92
+ suffixRanges: []
93
+ };
94
+ firstLine = anchorLine;
95
+ lastLine = anchorLine;
96
+ vpStart = anchorLineStart;
97
+ vpEnd = anchorLineEnd;
64
98
  }
65
- return count;
99
+ const hasPrefix = firstLine > 0 && vpStart > 0;
100
+ const hasSuffix = lastLine + 1 < lineStartsView.length && vpEnd < source.length;
101
+ const prefixRanges = [];
102
+ const viewportRanges = [];
103
+ const suffixRanges = [];
104
+ for (const range of ranges) {
105
+ if (hasPrefix) pushIntersection(prefixRanges, range, 0, vpStart - 1);
106
+ pushIntersection(viewportRanges, range, vpStart, vpEnd);
107
+ if (hasSuffix) pushIntersection(suffixRanges, range, vpEnd + 1, source.length);
108
+ }
109
+ return {
110
+ viewportSpan: {
111
+ start: vpStart,
112
+ end: vpEnd
113
+ },
114
+ viewportRanges,
115
+ prefixRanges,
116
+ suffixRanges
117
+ };
118
+ }
119
+ /**
120
+ * Creates a resumable scanner that yields after each cooperative slice.
121
+ *
122
+ * Keeps at most `limit` matches and sets `truncated: true` if an additional
123
+ * match exists past `limit` (stopping immediately without scanning further).
124
+ * A `limit` of `0` collects nothing and only checks whether any match exists.
125
+ * When `minMatchStart` is given, matches starting before that offset are
126
+ * skipped while scanning from whole-line boundaries so regexes and word
127
+ * boundaries remain exact.
128
+ */
129
+ function createFindRangeScanner(source, query, ranges, limit, minMatchStart = 0) {
130
+ const compiled = compileFindQuery(query);
131
+ if (!compiled || limit < 0 || ranges !== null && ranges.length === 0) return { step: () => ({
132
+ matches: [],
133
+ done: true,
134
+ truncated: false,
135
+ windowsScanned: 0
136
+ }) };
137
+ const normalized = searchRanges(source, ranges);
138
+ if (compiled.plan.kind === "range") return createWholeRangeScanner(source, compiled, normalized, limit, minMatchStart);
139
+ if (compiled.plan.kind === "literal-lines") return createSpanningLiteralScanner(source, compiled, normalized, compiled.plan.lineBreaks, limit, minMatchStart);
140
+ return createLineRangeScanner(source, compiled, normalized, limit, minMatchStart);
66
141
  }
67
142
  /** The line holding `offset`, break excluded. */
68
143
  function findLineRange(source, offset) {
@@ -254,7 +329,14 @@ function isLineSafeGroupOpener(pattern, index) {
254
329
  }
255
330
  function isLineSafeCharacterClass(body) {
256
331
  if (body.startsWith("^")) return false;
257
- return !body.includes("\\") && !body.includes("\n");
332
+ if (body.includes("\\") || body.includes("\n")) return false;
333
+ for (let index = 1; index < body.length - 1; index += 1) {
334
+ if (body[index] !== "-") continue;
335
+ const lo = body.charCodeAt(index - 1);
336
+ const hi = body.charCodeAt(index + 1);
337
+ if (lo <= 10 && hi >= 10) return false;
338
+ }
339
+ return true;
258
340
  }
259
341
  function characterClassEnd(pattern, from) {
260
342
  for (let index = from + 1; index < pattern.length; index += 1) if (pattern[index] === "\\") index += 1;
@@ -370,19 +452,34 @@ function lastWindowLine(source, first, start, rangeEnd) {
370
452
  const reach = Math.min(rangeEnd, start + FIND_WINDOW_UNITS);
371
453
  return Math.max(first, source.lineStartsView.indexForOffset(reach));
372
454
  }
373
- function scanLineWindow(window, query, range, captureMatches, visit) {
374
- if (query.plan.kind !== "anchored-lines") return scanWindow(window, query, range, captureMatches, visit);
375
- let lineStart = 0;
455
+ function scanLineWindow(window, query, range, captureMatches, visit, budget, startLineOffset = 0) {
456
+ if (query.plan.kind !== "anchored-lines") return scanWindow(window, query, range, captureMatches, visit, void 0, budget);
457
+ let lineStart = startLineOffset;
458
+ let linesChecked = 0;
376
459
  while (lineStart <= window.text.length) {
377
460
  const found = window.text.indexOf("\n", lineStart);
378
461
  const lineEnd = found === -1 ? window.text.length : found;
379
- const line = {
380
- text: window.text.slice(lineStart, lineEnd),
381
- start: window.start + lineStart,
382
- from: Math.max(0, window.from - lineStart)
383
- };
384
- if (lineEnd >= window.from && !scanWindow(line, query, range, captureMatches, visit)) return false;
462
+ if (lineEnd >= window.from) {
463
+ if (!scanWindow({
464
+ text: window.text.slice(lineStart, lineEnd),
465
+ start: window.start + lineStart,
466
+ from: Math.max(0, window.from - lineStart)
467
+ }, query, range, captureMatches, visit, void 0, budget)) {
468
+ if (budget?.yielded) {
469
+ budget.resumeAt = lineStart + budget.resumeAt;
470
+ budget.resumeLineStart = lineStart;
471
+ }
472
+ return false;
473
+ }
474
+ }
385
475
  lineStart = lineEnd + 1;
476
+ linesChecked += 1;
477
+ if (budget && lineStart <= window.text.length && linesChecked % REGEX_SLICE_CHECK_INTERVAL === 0 && nowMs() >= budget.deadline) {
478
+ budget.resumeAt = Math.max(window.from, lineStart);
479
+ budget.resumeLineStart = lineStart;
480
+ budget.yielded = true;
481
+ return false;
482
+ }
386
483
  }
387
484
  return true;
388
485
  }
@@ -418,12 +515,13 @@ function readWindow(source, start, end, range) {
418
515
  };
419
516
  }
420
517
  /** False once the range is spent or the visitor stopped, so no later window can add anything. */
421
- function scanWindow(window, query, range, captureMatches, visit, cursor) {
422
- if (query.simpleSearch && !captureMatches) return scanSimpleMatches(window, query.simpleSearch, query.wholeWord, range, visit, cursor);
423
- return scanRegexMatches(window, query, range, captureMatches, visit, cursor);
518
+ function scanWindow(window, query, range, captureMatches, visit, cursor, budget) {
519
+ if (query.simpleSearch && !captureMatches) return scanSimpleMatches(window, query.simpleSearch, query.wholeWord, range, visit, cursor, budget);
520
+ return scanRegexMatches(window, query, range, captureMatches, visit, cursor, budget);
424
521
  }
425
- function scanSimpleMatches(window, searchString, wholeWord, range, visit, cursor) {
522
+ function scanSimpleMatches(window, searchString, wholeWord, range, visit, cursor, budget) {
426
523
  let index = window.text.indexOf(searchString, window.from);
524
+ let iterations = 0;
427
525
  while (index !== -1) {
428
526
  const start = window.start + index;
429
527
  const end = start + searchString.length;
@@ -432,12 +530,20 @@ function scanSimpleMatches(window, searchString, wholeWord, range, visit, cursor
432
530
  if (validWholeWordMatch(window.text, index, searchString.length, wholeWord)) {
433
531
  if (!visit(start, end, null)) return false;
434
532
  }
435
- index = window.text.indexOf(searchString, index + searchString.length);
533
+ const nextFrom = index + searchString.length;
534
+ iterations += 1;
535
+ if (budget && iterations % REGEX_SLICE_CHECK_INTERVAL === 0 && nowMs() >= budget.deadline) {
536
+ budget.resumeAt = nextFrom;
537
+ budget.yielded = true;
538
+ return false;
539
+ }
540
+ index = window.text.indexOf(searchString, nextFrom);
436
541
  }
437
542
  return true;
438
543
  }
439
- function scanRegexMatches(window, query, range, captureMatches, visit, cursor) {
544
+ function scanRegexMatches(window, query, range, captureMatches, visit, cursor, budget) {
440
545
  query.regex.lastIndex = window.from;
546
+ let iterations = 0;
441
547
  while (true) {
442
548
  const match = query.regex.exec(window.text);
443
549
  if (!match) return true;
@@ -448,7 +554,16 @@ function scanRegexMatches(window, query, range, captureMatches, visit, cursor) {
448
554
  if (validWholeWordMatch(window.text, match.index, match[0].length, query.wholeWord)) {
449
555
  if (!visit(start, end, captureMatches ? match : null)) return false;
450
556
  }
451
- if (match[0].length === 0) advancePastEmptyMatch(query.regex, window.text);
557
+ if (match[0].length === 0) {
558
+ advancePastEmptyMatch(query.regex, window.text);
559
+ if (query.regex.lastIndex > window.text.length) return true;
560
+ }
561
+ iterations += 1;
562
+ if (budget && iterations % REGEX_SLICE_CHECK_INTERVAL === 0 && nowMs() >= budget.deadline) {
563
+ budget.resumeAt = query.regex.lastIndex;
564
+ budget.yielded = true;
565
+ return false;
566
+ }
452
567
  }
453
568
  }
454
569
  function advancePastEmptyMatch(regex, text) {
@@ -464,6 +579,346 @@ function validWholeWordMatch(text, start, length, wholeWord) {
464
579
  end: start + length
465
580
  });
466
581
  }
467
- export { FIND_MATCHES_LIMIT, FIND_REPLACE_ALL_LIMIT, FIND_WINDOW_UNITS, countMatches, escapeRegExpCharacters, findLineRange, findMatchIndex, findMatches, findNextMatchFrom, findPreviousMatchFrom, findTextSourceFromSnapshot };
582
+ function boundedPrioritySpan(source, visibleRange, anchorOffset) {
583
+ const anchor = clampSourceOffset(source, anchorOffset);
584
+ if (!visibleRange) return {
585
+ start: Math.max(0, anchor - FIND_VIEWPORT_FALLBACK_HALF_UNITS),
586
+ end: Math.min(source.length, anchor + FIND_VIEWPORT_FALLBACK_HALF_UNITS)
587
+ };
588
+ const start = clampSourceOffset(source, visibleRange.start);
589
+ const end = clampSourceOffset(source, Math.max(visibleRange.start, visibleRange.end));
590
+ if (end - start <= 131072) return {
591
+ start,
592
+ end
593
+ };
594
+ const clampedStart = anchor >= start && anchor <= end ? Math.max(start, Math.min(anchor - 65536, end - FIND_VIEWPORT_SYNC_MAX_UNITS)) : start;
595
+ return {
596
+ start: clampedStart,
597
+ end: clampedStart + FIND_VIEWPORT_SYNC_MAX_UNITS
598
+ };
599
+ }
600
+ function pushIntersection(target, range, lo, hi) {
601
+ const start = Math.max(range.start, lo);
602
+ const end = Math.min(range.end, hi);
603
+ if (start <= end) target.push({
604
+ start,
605
+ end
606
+ });
607
+ }
608
+ function createLineRangeScanner(source, query, ranges, limit, minMatchStart) {
609
+ const lineStartsView = source.lineStartsView;
610
+ let rangeIndex = 0;
611
+ let lineIndex = -1;
612
+ let activeWindow = null;
613
+ let activeWindowLastLine = -1;
614
+ let activeLineStart = 0;
615
+ let collected = 0;
616
+ let done = false;
617
+ let truncated = false;
618
+ return { step(budgetMs = 4, maxWindows = 32) {
619
+ if (done) return {
620
+ matches: [],
621
+ done: true,
622
+ truncated,
623
+ windowsScanned: 0
624
+ };
625
+ const sliceMatches = [];
626
+ const deadline = nowMs() + budgetMs;
627
+ let windowsScanned = 0;
628
+ while (rangeIndex < ranges.length) {
629
+ const range = ranges[rangeIndex];
630
+ if (!activeWindow) {
631
+ if (lineIndex < 0) lineIndex = lineStartsView.indexForOffset(range.start);
632
+ const start = lineStartsView.at(lineIndex);
633
+ if (start === void 0 || start > range.end) {
634
+ rangeIndex += 1;
635
+ lineIndex = -1;
636
+ continue;
637
+ }
638
+ activeWindowLastLine = lastWindowLine(source, lineIndex, start, range.end);
639
+ activeWindow = readWindow(source, start, lineEndAt(source, activeWindowLastLine), range);
640
+ activeLineStart = 0;
641
+ }
642
+ const budget = {
643
+ deadline,
644
+ resumeAt: activeWindow.from,
645
+ resumeLineStart: activeLineStart,
646
+ yielded: false
647
+ };
648
+ scanLineWindow(activeWindow, query, range, false, (matchStart, matchEnd, captures) => {
649
+ if (matchStart < minMatchStart) return true;
650
+ if (collected >= limit) {
651
+ truncated = true;
652
+ return false;
653
+ }
654
+ sliceMatches.push({
655
+ start: matchStart,
656
+ end: matchEnd,
657
+ matches: captures
658
+ });
659
+ collected += 1;
660
+ return true;
661
+ }, budget, activeLineStart);
662
+ if (truncated) {
663
+ activeWindow = null;
664
+ done = true;
665
+ return {
666
+ matches: sliceMatches,
667
+ done: true,
668
+ truncated: true,
669
+ windowsScanned
670
+ };
671
+ }
672
+ if (budget.yielded) {
673
+ activeWindow = {
674
+ ...activeWindow,
675
+ from: budget.resumeAt
676
+ };
677
+ activeLineStart = budget.resumeLineStart;
678
+ return {
679
+ matches: sliceMatches,
680
+ done: false,
681
+ truncated: false,
682
+ windowsScanned
683
+ };
684
+ }
685
+ activeWindow = null;
686
+ activeLineStart = 0;
687
+ lineIndex = activeWindowLastLine + 1;
688
+ const nextStart = lineStartsView.at(lineIndex);
689
+ if (nextStart === void 0 || nextStart > range.end) {
690
+ rangeIndex += 1;
691
+ lineIndex = -1;
692
+ }
693
+ windowsScanned += 1;
694
+ if (rangeIndex >= ranges.length) {
695
+ done = true;
696
+ return {
697
+ matches: sliceMatches,
698
+ done: true,
699
+ truncated: false,
700
+ windowsScanned
701
+ };
702
+ }
703
+ if (windowsScanned >= maxWindows || nowMs() >= deadline) return {
704
+ matches: sliceMatches,
705
+ done: false,
706
+ truncated: false,
707
+ windowsScanned
708
+ };
709
+ }
710
+ done = true;
711
+ return {
712
+ matches: sliceMatches,
713
+ done: true,
714
+ truncated: false,
715
+ windowsScanned
716
+ };
717
+ } };
718
+ }
719
+ function createSpanningLiteralScanner(source, query, ranges, lineBreaks, limit, minMatchStart) {
720
+ const lineStartsView = source.lineStartsView;
721
+ let rangeIndex = 0;
722
+ let first = -1;
723
+ let finalLine = -1;
724
+ let cursor = { offset: 0 };
725
+ let activeWindow = null;
726
+ let activeWindowLast = -1;
727
+ let collected = 0;
728
+ let done = false;
729
+ let truncated = false;
730
+ return { step(budgetMs = 4, maxWindows = 32) {
731
+ if (done) return {
732
+ matches: [],
733
+ done: true,
734
+ truncated,
735
+ windowsScanned: 0
736
+ };
737
+ const sliceMatches = [];
738
+ const deadline = nowMs() + budgetMs;
739
+ let windowsScanned = 0;
740
+ while (rangeIndex < ranges.length) {
741
+ const range = ranges[rangeIndex];
742
+ if (!activeWindow) {
743
+ if (first < 0) {
744
+ first = lineStartsView.indexForOffset(range.start);
745
+ finalLine = lineStartsView.indexForOffset(range.end);
746
+ cursor = { offset: range.start };
747
+ }
748
+ if (first > finalLine) {
749
+ rangeIndex += 1;
750
+ first = -1;
751
+ continue;
752
+ }
753
+ const start = lineStartsView.at(first) ?? 0;
754
+ activeWindowLast = Math.min(finalLine, Math.max(first + lineBreaks, lastWindowLine(source, first, start, range.end)));
755
+ activeWindow = {
756
+ text: source.readRange(start, Math.max(start, lineEndAt(source, activeWindowLast))),
757
+ start,
758
+ from: Math.max(0, cursor.offset - start)
759
+ };
760
+ }
761
+ const budget = {
762
+ deadline,
763
+ resumeAt: activeWindow.from,
764
+ resumeLineStart: 0,
765
+ yielded: false
766
+ };
767
+ scanWindow(activeWindow, query, range, false, (matchStart, matchEnd, captures) => {
768
+ if (matchStart < minMatchStart) return true;
769
+ if (collected >= limit) {
770
+ truncated = true;
771
+ return false;
772
+ }
773
+ sliceMatches.push({
774
+ start: matchStart,
775
+ end: matchEnd,
776
+ matches: captures
777
+ });
778
+ collected += 1;
779
+ return true;
780
+ }, cursor, budget);
781
+ if (truncated) {
782
+ activeWindow = null;
783
+ done = true;
784
+ return {
785
+ matches: sliceMatches,
786
+ done: true,
787
+ truncated: true,
788
+ windowsScanned
789
+ };
790
+ }
791
+ if (budget.yielded) {
792
+ activeWindow = {
793
+ ...activeWindow,
794
+ from: budget.resumeAt
795
+ };
796
+ return {
797
+ matches: sliceMatches,
798
+ done: false,
799
+ truncated: false,
800
+ windowsScanned
801
+ };
802
+ }
803
+ activeWindow = null;
804
+ windowsScanned += 1;
805
+ if (activeWindowLast === finalLine) {
806
+ rangeIndex += 1;
807
+ first = -1;
808
+ } else first = activeWindowLast + 1 - lineBreaks;
809
+ if (rangeIndex >= ranges.length) {
810
+ done = true;
811
+ return {
812
+ matches: sliceMatches,
813
+ done: true,
814
+ truncated: false,
815
+ windowsScanned
816
+ };
817
+ }
818
+ if (windowsScanned >= maxWindows || nowMs() >= deadline) return {
819
+ matches: sliceMatches,
820
+ done: false,
821
+ truncated: false,
822
+ windowsScanned
823
+ };
824
+ }
825
+ done = true;
826
+ return {
827
+ matches: sliceMatches,
828
+ done: true,
829
+ truncated: false,
830
+ windowsScanned
831
+ };
832
+ } };
833
+ }
834
+ function createWholeRangeScanner(source, query, ranges, limit, minMatchStart) {
835
+ const lineStartsView = source.lineStartsView;
836
+ let rangeIndex = 0;
837
+ let activeWindow = null;
838
+ let collected = 0;
839
+ let done = false;
840
+ let truncated = false;
841
+ return { step(budgetMs = 4, maxWindows = 32) {
842
+ if (done) return {
843
+ matches: [],
844
+ done: true,
845
+ truncated,
846
+ windowsScanned: 0
847
+ };
848
+ const sliceMatches = [];
849
+ const deadline = nowMs() + budgetMs;
850
+ let windowsScanned = 0;
851
+ while (rangeIndex < ranges.length) {
852
+ const range = ranges[rangeIndex];
853
+ if (!activeWindow) {
854
+ const start = lineStartsView.at(lineStartsView.indexForOffset(range.start)) ?? 0;
855
+ const end = lineEndAt(source, lineStartsView.indexForOffset(range.end));
856
+ activeWindow = readWindow(source, start, Math.max(start, end), range);
857
+ }
858
+ const budget = {
859
+ deadline,
860
+ resumeAt: activeWindow.from,
861
+ resumeLineStart: 0,
862
+ yielded: false
863
+ };
864
+ scanRegexMatches(activeWindow, query, range, false, (matchStart, matchEnd, captures) => {
865
+ if (matchStart < minMatchStart) return true;
866
+ if (collected >= limit) {
867
+ truncated = true;
868
+ return false;
869
+ }
870
+ sliceMatches.push({
871
+ start: matchStart,
872
+ end: matchEnd,
873
+ matches: captures
874
+ });
875
+ collected += 1;
876
+ return true;
877
+ }, void 0, budget);
878
+ if (truncated) {
879
+ activeWindow = null;
880
+ done = true;
881
+ return {
882
+ matches: sliceMatches,
883
+ done: true,
884
+ truncated: true,
885
+ windowsScanned
886
+ };
887
+ }
888
+ if (budget.yielded) {
889
+ activeWindow = {
890
+ ...activeWindow,
891
+ from: budget.resumeAt
892
+ };
893
+ return {
894
+ matches: sliceMatches,
895
+ done: false,
896
+ truncated: false,
897
+ windowsScanned
898
+ };
899
+ }
900
+ activeWindow = null;
901
+ rangeIndex += 1;
902
+ windowsScanned += 1;
903
+ if (rangeIndex < ranges.length && (windowsScanned >= maxWindows || nowMs() >= deadline)) return {
904
+ matches: sliceMatches,
905
+ done: false,
906
+ truncated: false,
907
+ windowsScanned
908
+ };
909
+ }
910
+ done = true;
911
+ return {
912
+ matches: sliceMatches,
913
+ done: true,
914
+ truncated: false,
915
+ windowsScanned
916
+ };
917
+ } };
918
+ }
919
+ function nowMs() {
920
+ return globalThis.performance?.now() ?? Date.now();
921
+ }
922
+ export { FIND_MATCHES_LIMIT, FIND_REPLACE_ALL_LIMIT, FIND_SELECT_ALL_LIMIT, FIND_SYNC_THRESHOLD, FIND_VIEWPORT_SYNC_MAX_UNITS, FIND_WINDOW_UNITS, createFindRangeScanner, escapeRegExpCharacters, findLineRange, findMatchIndex, findMatches, findNextMatchFrom, findPreviousMatchFrom, findQueryPlan, findTextSourceFromSnapshot, partitionViewportRanges, searchedRangesLength };
468
923
 
469
924
  //# sourceMappingURL=search.js.map