Clear AI block find highlights when the find bar closes#11458
Draft
maxmilian wants to merge 1 commit into
Draft
Conversation
`TerminalView::close_find_bar` only set `is_find_bar_open` to false and notified the terminal view itself. AI blocks are separate child views whose find highlights are gated on `is_find_bar_open()` at render time, but nothing notified them to repaint when the find bar closed, so stale highlights persisted until the pane was refocused. Terminal grid blocks were unaffected because the terminal view repaints itself on close. Call `find_model.clear_matches()` from `close_find_bar` so every registered rich-content child view clears its cached find state and repaints, mirroring how `open_find_bar` runs find on open. Fixes warpdotdev#11212 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
a19cddd to
578c91a
Compare
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.
Summary
Closing the find bar left stale find highlights on AI blocks until the pane was refocused.
close_find_barnow clears find matches so AI block child views repaint immediately. Fixes #11212.Root cause
TerminalView::close_find_bar(app/src/terminal/view.rs) only setis_find_bar_opentofalseand calledctx.notify()on the terminal view itself. AI block find highlights are gated onis_find_bar_open()at render time (app/src/ai/blocklist/block/view_impl.rs), but AI blocks are separate child views — nothing notified them to repaint when the find bar closed, so their last-rendered highlights persisted until another repaint (e.g. pane refocus). Terminal grid blocks were unaffected because the terminal view repaints itself on close.Fix
close_find_barnow also callsfind_model.clear_matches(). That clears each registered rich-content child view's cached find state and notifies it to repaint — mirroring howopen_find_barruns find on open. Both the sync (clear_matches) and async (clear_results) find paths already iterate registered rich-content views, so the fix covers both.Tests
Added
close_find_bar_clears_ai_block_find_highlightsinapp/src/terminal/view_tests.rs: builds an AI block with a searchable query, highlights a match, closes the find bar, and asserts the AI block's find match count drops to0. The test fails before this change (highlights persist,left: 1, right: 0) and passes after.cargo fmt --check,cargo clippy --tests -D warnings, and the test all pass locally.The test drives the AI block's
run_finddirectly because the blocklist find pipeline only visits rich-content views once they have been laid out, which does not happen in a headless test; this is noted in a comment in the test.Visual evidence
Scope
close_find_baris touched; opening find and live find updates are unchanged.#[cfg(test)]accessors (FindState::match_count,AIBlock::find_match_count) exist solely so the regression test can observe AI block find state.CHANGELOG-BUG-FIX: Fixed find highlights lingering on AI blocks after closing the find bar.