Commit Graph
11044 Commits
Author SHA1 Message Date
Daniel Imms fe9ebddd6f New benchmark case for cold cache 2026-05-26 07:56:36 -07:00
Daniel ImmsandCursor c6d72b7db6 Guard and streamline cold-path next-match scanning.
This limits the cold fast path to repeated successful non-decorated searches and scans logical lines lazily, preserving general behavior while driving findNext/cold cache well past the 10x target.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 07:38:22 -07:00
Daniel ImmsandCursor 9add7789b2 Short-circuit cold findNext to first navigable match.
This adds a cold-path fast search for non-decorated findNext so cache-cleared scans can stop after finding the next selection target instead of materializing all matches.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 07:31:55 -07:00
Daniel ImmsandCursor c55a248d52 Use canonical BufferLine translation for search line text.
This enables BufferLine internal full-line string caching on cold-cache searches and substantially reduces findNext cold-cache runtime.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 07:18:55 -07:00
Daniel ImmsandCursor 0f0c615748 Use BufferLine translation for search logical text rebuild.
This reduces per-cell work in cold-cache searches by using the optimized line translation path while preserving match behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 07:11:49 -07:00
Daniel ImmsandCursor 9309ccc480 Prevent SearchAddon decorations from obscuring canvas text.
Remove inline decoration background styling and dispose inactive cached decoration sets so stale overlays do not render over glyphs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 22:33:00 -07:00
Daniel ImmsandCursor ecd846c027 Remove unused SearchAddon state and parameters.
Drop the unused `_lastDirection` field and remove unused method parameters introduced by prior refactors so SearchAddon internals stay minimal and easier to follow without behavior changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 22:15:54 -07:00
Daniel ImmsandCursor 7ddca3a305 Move SearchAddon limits to documented const enum.
Replace static readonly class limit fields with an internal const enum and add JSDoc for each limit so cache and highlight bounds are centralized and self-describing.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 22:13:09 -07:00
Daniel ImmsandCursor 5ff85db4f3 Refactor SearchAddon state/navigation helpers for readability.
Consolidate duplicated search-state and index-stepping logic into small private helpers, and centralize decoration width/render setup to reduce drift between active/inactive paths. Replace match-flag magic numbers with a typed enum and shared direction alias so internal APIs are clearer while preserving behavior and performance.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 22:11:00 -07:00
Daniel ImmsandCursor ef84237ef3 Coalesce write-triggered decoration refreshes within the same tick.
This avoids redundant match/decorations recomputation during bursts of parsed writes while preserving the latest refresh result.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 22:00:36 -07:00
Daniel ImmsandCursor 2da6c9b9b7 Cache match decoration sets across searches with a small LRU.
This avoids tearing down and recreating all match decorations when users revisit recent search terms, which significantly reduces decoration refresh overhead in alternating-term search flows.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 21:59:44 -07:00
Daniel ImmsandCursor eb55fd4ba3 Avoid selection lookups when navigation state already identifies the next result.
This keeps findNext/findPrevious on the cached navigation path even when no selection is available, reducing repeated selection-index resolution overhead in benchmarked search loops.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 21:58:29 -07:00
Daniel Imms 1f3ebe1b91 Add element back to benchmark common case 2026-05-25 21:02:19 -07:00
Daniel Imms dc01e4e97b Add test around viewport scrolling behavior 2026-05-25 21:00:49 -07:00
Daniel ImmsandCursor 9bd72abc59 Optimize SearchAddon hot paths and skip headless decoration work.
Reduce repeated search overhead with faster cache/index paths and avoid creating decorations when no terminal DOM is attached, significantly cutting benchmark runtime in decoration-heavy scenarios.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 20:54:42 -07:00
Daniel ImmsandCursor d179d586e9 Optimize addon-search search hot paths with reusable match and logical-line caches.
Avoid recomputing full-buffer scans on repeated queries and defer expensive offset mapping work until matches are found, reducing navigation and refresh benchmark runtimes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 20:37:49 -07:00
Daniel Imms 3b56138d0a Re-implement addon-search 2026-05-25 20:18:14 -07:00
Daniel Imms 950f1be20d Stub SearchAddon.ts 2026-05-25 20:06:08 -07:00
Daniel Imms 41841d0aa8 Remove old search impl 2026-05-25 19:58:20 -07:00
Daniel ImmsandCursor 3bebe6c18e chore(addon-search): ignore generated benchmark output
Exclude out-benchmark from version control to avoid accidental commits
of compiled benchmark artifacts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:15:29 -07:00
Daniel ImmsandCursor a344c36940 docs(addon-search): align README and public typings
Clarify decorations usage, result event semantics, whole-word boundaries,
and export ISearchDecorationOptions.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:15:29 -07:00
Daniel ImmsandCursor fedf29e870 test(addon-search): add wholeWord and reverse-regex benchmarks
Add benchmark coverage for whole-word navigation and reverse regex
whole-word searches to guard optimization regressions.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:15:29 -07:00
Daniel ImmsandCursor 7fbe5a27fa fix(addon-search): harden search state and lifecycle
Normalize and snapshot search options, clear stale decorations when
decorations are disabled, use try/finally for search events, and refresh
highlights without re-entering public navigation APIs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:15:28 -07:00
Daniel ImmsandCursor d4a8e5f50e perf(addon-search): O(1) tracked result index lookup
Rebuild a result key map on updateResults and manage selected decoration
lifecycle with MutableDisposable.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:15:28 -07:00
Daniel ImmsandCursor 8405d584d8 perf(addon-search): streamline decoration creation
Create highlight decorations in a single pass, dispose markers when
registration fails, and reduce per-decoration allocation overhead.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:15:28 -07:00
Daniel ImmsandCursor 3ee7df2596 perf(addon-search): SearchEngine micro-optimizations
Hoist buffer bounds, reuse prepared plain terms, fast-path non-wholeWord
indexOf, and use match size for highlight collection wrap checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:15:28 -07:00
Daniel ImmsandCursor 0440861b84 perf(addon-search): memoize repeated no-match searches
Track buffer cache generation and skip full-buffer scans when the same
term, options, and start position previously produced no match until the
line cache is invalidated.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:12:47 -07:00
Daniel ImmsandCursor 73c99a8412 perf(addon-search): collect highlight matches in one search session
Add SearchEngine.collectMatches to initialize cache and regex once while
gathering matches, and use it from _highlightAllMatches instead of
repeated find() calls.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:06:23 -07:00
Daniel ImmsandCursor e5ffbe315a perf(addon-search): optimize regex search hot path
Unify regex and whole-word matching into a single scan pass and avoid
per-line substring allocations by searching the full logical line with
lastIndex. Forward non-whole-word regex keeps a single-exec fast path.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 19:04:22 -07:00
Daniel ImmsandCursor 510a1b0d75 test(addon-search): remove debugger from integration tests
Drop accidental debugger statement and unnecessary delay in
onDidChangeResults coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 18:02:22 -07:00
Daniel ImmsandCursor 74bec251e6 docs(addon-search): align API docs with runtime behavior
Clarify incremental search, result event semantics, highlightLimit, and
optional decoration overview ruler fields.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 18:02:22 -07:00
Daniel ImmsandCursor 6d08f5938d test(addon-search): add regression tests for search state and edge cases
Add SearchState and SearchResultTracker unit tests plus whole-word,
reverse-regex, and lowercase cache coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 18:02:22 -07:00
Daniel ImmsandCursor ee322c811f fix(addon-search): skip overview ruler when colors are omitted
Support optional overview ruler colors from decoration options without
passing undefined into terminal decoration registration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 18:02:22 -07:00
Daniel ImmsandCursor 811be7b1ac fix(addon-search): prevent infinite loop on empty reverse regex matches
Advance regex lastIndex when skipping zero-length matches during reverse
search to avoid hanging on patterns like .*?

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 18:02:22 -07:00
Daniel ImmsandCursor 17dd1ede33 chore(addon-search): improve benchmark coverage and eval thresholds
Add no-match and case-insensitive benchmark cases, validate found counts,
tighten SearchAddon runtime tolerances, and use 10-run baseline/eval passes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:43:19 -07:00
Daniel ImmsandCursor 2146e4940d fix(addon-search): normalize invalid highlightLimit values
Clamp highlightLimit to a positive finite integer, falling back to the
default when the option is missing or invalid.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:42:22 -07:00
Daniel ImmsandCursor d99803293e fix(addon-search): cancel pending highlight refresh on clear
Clear the debounced highlight timeout when decorations are cleared to
avoid stale delayed searches.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:42:22 -07:00
Daniel ImmsandCursor f28bfb7142 perf(addon-search): avoid redundant result array copy in tracker
Skip slicing when the caller already respects the highlight limit.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:42:17 -07:00
Daniel ImmsandCursor e4ebd082ce perf(addon-search): cache lowercased line text in line cache
Lazily store a lowercased line variant in the line cache entry to avoid
repeated toLowerCase calls during case-insensitive searches.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:41:58 -07:00
Daniel ImmsandCursor a7467a901d perf(addon-search): reuse compiled regex across line scans
Compile the line search RegExp once per find/findNext/findPrevious call
and pass it into _findInLine to avoid per-line recompilation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:41:28 -07:00
Daniel ImmsandCursor 9902f54c93 perf(addon-search): avoid repeated substring allocation in reverse regex
Hoist searchStringLine.slice(0, offset) outside the reverse regex exec loop.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:40:31 -07:00
Daniel ImmsandCursor c7baa96f97 fix(addon-search): ignore zero-length matches in reverse regex search
Skip empty regex matches in the reverse path to match forward behavior and
avoid unstable result selection.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:39:23 -07:00
Daniel ImmsandCursor 11720c9dc3 fix(addon-search): continue whole-word search within same line
Scan for additional matches when the first candidate fails whole-word
checks instead of returning early.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:38:35 -07:00
Daniel ImmsandCursor 0b1cacd1a5 fix(addon-search): apply active result decoration CSS class
Pass isActiveResult through to _applyStyles in onRender so active matches
receive xterm-find-active-result-decoration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:37:45 -07:00
Daniel ImmsandCursor 865f835a5e fix(addon-search): refresh highlights when decoration options change
Compare decoration style fields in didOptionsChange so same-term searches
with updated colors or rulers trigger highlight recomputation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:36:56 -07:00
Daniel ImmsandCursor bf055dd5fc fix(addon-search): rehighlight when search options change
Evaluate shouldUpdateHighlighting before updating lastSearchOptions so
option-only changes trigger highlight refresh for the same term.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 17:36:06 -07:00
Daniel Imms 255859606c Add search benchmark 2026-05-25 16:34:58 -07:00
Daniel Imms e749cb6125 Merge pull request #5891 from Tyriar/cross-env
Remove cross-env dep
2026-05-21 03:17:50 -07:00
Daniel Imms 8df996f9e7 Merge pull request #5892 from Tyriar/tyriar/deps
Remove @types/debug and trusted-types
2026-05-21 03:17:24 -07:00
Daniel Imms 51f6186352 Remove @types/debug and trusted-types 2026-05-21 03:09:41 -07:00