Skip to content

Fix find focus drifting when output streams into active block#10057

Merged
seemeroland merged 1 commit intowarpdotdev:masterfrom
amazansky:amazansky/9542-fix-find-focus-drift
May 6, 2026
Merged

Fix find focus drifting when output streams into active block#10057
seemeroland merged 1 commit intowarpdotdev:masterfrom
amazansky:amazansky/9542-fix-find-focus-drift

Conversation

@amazansky
Copy link
Copy Markdown
Contributor

Description

When using cmd+f to search a block whose output is still streaming, the currently selected match jumps to a different piece of text as new matches are appended. This happens because BlockListFindRun::rerun_on_block() preserves the raw focused-match index when splicing updated matches for the active block — as new matches stream in, the same numeric index points to a different span.

Fix: Before splicing, snapshot the currently focused BlockListMatch. After splicing, relocate it in the updated vector by comparing span identity (block_index, grid_type, range) via a new same_span() helper. If the focused match was outside the rerun block's slice, shift the index by the delta in match count. Also handles the "no old matches" (new block) case by shifting the index forward.

Linked Issue

Closes #9542

  • The linked issue is labeled ready-to-implement (triaged bug — implicitly ready-to-implement per CONTRIBUTING.md).
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

Added two regression tests in block_list_test.rs:

  • test_rerun_on_block_preserves_focused_match_in_active_block — focuses the prompt match inside a streaming block, appends new output with additional matches, verifies focus stays on the same span.
  • test_rerun_on_block_preserves_focused_match_in_older_block — focuses a match in an older finished block, appends output to the active block, verifies the focused match and its UI index shift correctly.

All 10 terminal find tests pass. cargo fmt and cargo clippy -p warp --tests pass clean.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Conversation link

CHANGELOG-BUG-FIX: Fixed find (cmd+f) selection jumping to a different match when new output streams into the active block.
-->

Co-Authored-By: Oz [email protected]

When the find bar is open and the active block's output is still
streaming, rerun_on_block() splices new matches into the match vector
but previously kept raw_focused_match_index unchanged. This caused the
highlighted match to visibly jump to whatever text now occupied that
numeric position.

Fix: before splicing, snapshot the currently focused match. After
splicing, relocate it in the updated vector by comparing the match's
span identity (block_index, grid_type, range). If the focused match was
outside the rerun block's slice, shift the index by the change in match
count instead. A new same_span() helper on BlockListMatch compares
matches ignoring transient state like is_filtered.

Added two regression tests exercising both cases:
- focused match inside the active (streaming) block
- focused match in an older block while the active block grows

Closes warpdotdev#9542

Co-Authored-By: Oz <[email protected]>
@cla-bot cla-bot Bot added the cla-signed label May 4, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 4, 2026

@amazansky

I'm starting a first review of this pull request.

I reviewed this pull request and requested human review from: @seemeroland.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 4, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR preserves find focus across active-block reruns by snapshotting the focused match and relocating it by span identity after refreshed matches are spliced in. The added regression tests cover focus preservation within the streaming block and focus index shifting for an older block.

Concerns

  • None.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot requested a review from seemeroland May 4, 2026 16:13
Copy link
Copy Markdown
Contributor

@seemeroland seemeroland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find and fix - I was able to reproduce the issue and confirm that this branch fixes it locally. Thanks for the contribution!

@seemeroland seemeroland enabled auto-merge (squash) May 6, 2026 04:01
@seemeroland seemeroland merged commit 69638b8 into warpdotdev:master May 6, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find (cmd+f) selection jumps to a different match when new output streams in, instead of staying on the same text

2 participants