Repository navigation
fix(terminal): clear stale search highlights when find closes - #9519
Merged
nwparker merged 1 commit intoJul 24, 2026
Merged
Conversation
kaynansc
marked this pull request as ready for review
July 20, 2026 05:18
Contributor
📝 WalkthroughWalkthroughTerminalSearch now uses a shared cleanup helper that clears Xterm decorations and resets search navigation with an empty query. Cleanup runs when the search closes, the query is erased, the search addon changes, or the component unmounts. A new test suite verifies these behaviors for query clearing, addon switching, and unmount cleanup. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nwparker
force-pushed
the
kaynansc/fix-desktop-find-search
branch
from
July 23, 2026 11:49
b20b6ec to
f89a91b
Compare
Contributor
|
Thanks so much for this, @kaynansc — clear stale search highlights when find closes. Verified (fail-on-main/pass-on-branch), rebased on latest |
This was referenced Jul 27, 2026
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
Co-authored-by: kaynan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(terminal): clear stale search highlights when find closes
Summary
Fixes stale terminal find highlights that lingered after the query was erased, the active pane changed, or the search overlay unmounted.
ELI5
When you searched in the terminal and then cleared or closed the search, the highlighted match sometimes stayed lit up. Now it disappears the moment the search stops.
Root cause & fix
SearchAddon.clearDecorations()removes xterm's painted match decorations but leaves the active match still selected, andTerminalSearchnever cleaned up the previous addon when its portal moved to another pane or unmounted. The fix adds aclearTerminalSearch()helper that pairsclearDecorations()with afindNext('')empty-find request — xterm's path for dropping the active selection — and applies it on query erase, search-closed, addon change, and portal unmount. A separate addon-lifecycle effect keyed onsearchAddoncleans the previous pane without resetting incremental search on every keystroke.Evidence
Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.
origin/main(base8a23618310, headb20b6ecbc2).src/renderer/src/components/TerminalSearch.test.tsx(new) — 3/3 pass on branch.TerminalSearch.tsx) while keeping the test → 3/3 fail, proving the tests catch the regression:npx oxlint src/renderer/src/components/TerminalSearch.tsx— clean (no warnings/errors).Trade-offs
None — pure fix. (Searching history owned internally by an alternate-screen TUI remains a separate, pre-existing limitation, since that history is not in xterm's active buffer.)
Regression risk
Effectively zero. The change is renderer-only and scoped to the terminal-search cleanup path: cleanup runs only when search is cleared/closed, the addon changes, or the portal unmounts. Non-affected code paths are byte-identical to
origin/main, and the empty-find call short-circuits without scanning the buffer. The three regression tests prove correct behavior across all three failure paths.Credit to @kaynansc for the original fix. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.