G
YouTube TikTok Games
Skip to content

fix(search): refresh F3 matches after edits with find closed - #947

Merged
eugenioenko merged 1 commit into
eugenioenko:mainfrom
mangeshraut712:cursor/fix-f3-stale-matches-508e
Oct 18, 2026
Merged

eugenioenko merged 1 commit into
eugenioenko:mainfrom
mangeshraut712:cursor/fix-f3-stale-matches-508e

Conversation

@mangeshraut712

@mangeshraut712 mangeshraut712 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Closing the find bar keeps the query, and the next F3 rebuilds matches. Those matches were then treated as current for as long as the buffer and query stayed the same, so an edit after that left F3 and Shift+F3 on the old lines.

findSession now stores the buffer version the matches were computed against. refreshFindSearch rescans when that version moves, including while the bar is closed.

The first F3 right after Escape already rescanned, because closing the bar clears the displayed query. The stale jump is the F3 after a later edit. The functional test does that: search foo (lines 3 and 6), Escape, F3, go to line 1, insert two lines, F3.

Tested:

  • go test ./internal/ui/ -count=1 -run 'TestFind(Next|Prev)After'
  • make test (pass)
  • make lint (golangci-lint 2.15.0, 0 issues)
  • make build && cd tests/functional && pnpm install && pnpm test audit-findreplace-bugs (10 passed, 3 expected fail)
  • bin/ttt --size 80x24 --exec on a file with foo on lines 3 and 6. Before the fix, Escape, F3, Ctrl+Home, Enter, Enter, F3 left the cursor on one. After, the same script and Shift+F3 both land on foo.

Fixes #940

Open in Web Open in Cursor 

Note

Cursor Bugbot is generating a summary for commit 796465b. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Find Next and Find Previous now use current search matches after the buffer is edited, including when the find bar has been closed and reopened.

Find Next treated matches as current whenever the buffer and query were
unchanged. After the closed find bar restored those matches, an edit
left F3 and Shift+F3 on the old lines. Remember the buffer version the
matches were computed against and rescan when it moves.

Fixes #940

Co-authored-by: Mangesh Raut <mangeshraut712@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: eugenioenko/ttt/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6905570-659d-4d31-98d3-9584be1cb2c9
📥 Commits

Reviewing files that changed from the base of the PR and between 9e3adbb and 796465b.

📒 Files selected for processing: 3
  • internal/ui/editor_group.go
  • internal/ui/editor_group_find_refresh_test.go
  • tests/functional/audit-findreplace-bugs.test.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

Find search sessions now record the buffer version associated with cached matches. Search refresh checks that version before reusing matches and updates it after recomputation. Regression tests cover next and previous search navigation after buffer edits.

Changes: Find Match Refresh

Layer / File(s) Summary
Versioned find matches and regression coverage
internal/ui/editor_group.go, internal/ui/editor_group_find_refresh_test.go, tests/functional/audit-findreplace-bugs.test.js
The find session records the buffer version for cached matches. Refresh recomputes matches when the active buffer version changes. Tests cover next and previous navigation after edits, including F3 navigation with the find bar closed.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 79646

Find navigation refreshes cached matches after edits. No actionable merge-blocking risk remains after normal checks.

Pre-merge checks: Passed 4
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: refreshing F3 search matches after edits when the find bar is closed.
Linked Issues check Passed The implementation satisfies issue #940. findSession stores matchesVersion. refreshFindSearch rescans when the active buffer version differs from the cached version, including when the find bar …
Out of Scope Changes check Passed The changes stay within issue #940. The production change refreshes cached search matches after buffer edits. The added unit and functional tests verify this behavior. No unrelated production behavior…
Full details: Linked Issues check

Explanation

The implementation satisfies issue #940. findSession stores matchesVersion. refreshFindSearch rescans when the active buffer version differs from the cached version, including when the find bar is closed. The new unit tests cover FindNext and FindPrev after edits. The functional test covers the closed-bar F3 repro.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #940. The production change refreshes cached search matches after buffer edits. The added unit and functional tests verify this behavior. No unrelated production behavior or unrelated tests are present in the reviewed diff.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@eugenioenko eugenioenko left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you for helping make ttt better!

@eugenioenko
eugenioenko merged commit 0d4198b into eugenioenko:main Oct 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F3 uses stale matches after an edit when the find bar is closed

2 participants