Skip to content

fix(example): keep the find count right and reset the bar on file open - #35

Merged
SectionTN merged 2 commits into
mainfrom
fix/example-find
Nov 18, 2026
Merged

SectionTN merged 2 commits into
mainfrom
fix/example-find

Conversation

@SectionTN

@SectionTN SectionTN commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

the example's find bar subtracted one from the count after each replace. when the replacement still matches, like a case-insensitive "import" replaced with "IMPORT", it showed "2 of 3" while 4 matches were painted. replace all showed "no results" over the same painted matches. the bar now asks the editor for the selected match and the total after a replace, and for the count again after a replace all.

on Android and iOS, opening another file kept the find bar with the old query and count while the new editor had no search. the bar is keyed like the editor now, so it remounts with it, same as the web example.

Summary by CodeRabbit

  • Bug Fixes
    • Find and replace now updates match counts and selection accurately when replacement text still matches the search.
    • Opening a file resets the Find bar’s previous query and match count.

…tches

Replacing a case-insensitive "import" with "IMPORT" showed "2 of 3" while 4
matches were painted, since the bar subtracted one from the count after each
replace. Replace all showed "no results" over the same painted matches. The
bar now reads the selected match and the total from the editor after a
replace, and the count again after a replace all.
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The find bar remounts when the current file ID or open count changes. Replacing one or all matches now refreshes the match state from search results. Added tests cover replacement text that still matches the search.

Changes: Find and replace state

Layer / File(s) Summary
Refresh match state after replacement
example/src/chrome/useFind.ts, example/src/__tests__/useFind.test.ts
replaceOne updates the selection and match state from a fresh search result. replaceAll reruns the current search and sets the count and index from its results. Tests cover replacements that still match the query.
Reset find bar on file changes
example/src/EditorApp.tsx
FindBar is keyed by file ID and open count, so it remounts when either value changes.

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

Change: Bug fix

Possibly related PRs

Merge Risk: Low · up to 50128

Find and replace in the example app now reports match counts after replacements, and the find bar resets when another file is opened. Two edge cases remain. Typing a new query while Replace All is running can show the old query's count. A failed refresh after Replace One can leave the previous count with no status message. These are low-impact and limited to the example app, so the change is mergeable with these follow-ups.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@SectionTN
SectionTN merged commit d7a46d1 into main Nov 18, 2026
9 of 10 checks passed
@SectionTN
SectionTN deleted the fix/example-find branch November 18, 2026 15:26
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.

1 participant