Add Find & Replace functionality with Replace and Replace All actions - #180
Conversation
|
Warning Review limit reached
Next review available in: 35 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds find-and-replace to the in-note search: new ChangesFind-and-Replace Feature
Dev Server Host Fix
Sequence Diagram(s)sequenceDiagram
participant User
participant Editor
participant ProseMirror
participant SearchToolbar
rect rgba(100, 149, 237, 0.5)
note over User,SearchToolbar: Open Replace Panel
User->>Editor: Cmd/Ctrl+H
Editor->>Editor: setIsSearchOpen(true), setIsReplaceOpen(true)
Editor->>SearchToolbar: render replace row (isReplaceOpen=true)
end
rect rgba(144, 238, 144, 0.5)
note over User,ProseMirror: Replace Current Match
User->>SearchToolbar: type replaceQuery, click Replace
SearchToolbar->>Editor: onReplace()
Editor->>ProseMirror: dispatch transaction (replace active match)
ProseMirror-->>Editor: updated doc
Editor->>Editor: recompute matches, update decorations
end
rect rgba(255, 179, 71, 0.5)
note over User,ProseMirror: Replace All Matches
User->>SearchToolbar: click Replace All
SearchToolbar->>Editor: onReplaceAll()
Editor->>ProseMirror: dispatch transaction (all matches in reverse)
ProseMirror-->>Editor: updated doc
Editor->>Editor: recompute matches, reset to first match
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/editor/Editor.tsx`:
- Around line 1310-1330: In the replaceCurrent callback function, the nextIndex
calculation uses currentMatchIndex % newMatches.length which does not advance to
the next match when the replacement text contains the search query, causing the
replacement to target the same match repeatedly. Change the nextIndex
calculation from currentMatchIndex % newMatches.length to (currentMatchIndex +
1) % newMatches.length to ensure the function advances to the next match after
each replacement instead of potentially staying on the same location.
In `@src/components/editor/SearchToolbar.tsx`:
- Around line 73-79: The handleReplaceKeyDown function in SearchToolbar.tsx
currently triggers onReplaceAll when the user presses Enter with metaKey,
ctrlKey, or altKey modifiers. However, Alt+Enter should not trigger replace-all,
only Cmd/Ctrl+Enter should. Remove the e.altKey check from the conditional
statement in handleReplaceKeyDown that calls onReplaceAll, keeping only the
e.metaKey and e.ctrlKey checks. Apply the same fix to the similar location
mentioned at lines 165-169 where the same pattern exists.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e2f195ef-7333-4412-8a87-87c5dc8f338c
📒 Files selected for processing (5)
src-tauri/tauri.conf.jsonsrc/components/editor/Editor.tsxsrc/components/editor/SearchToolbar.tsxsrc/components/icons/index.tsxvite.config.ts
Cmd+H is reserved by macOS for Hide (bound in the default app menu), so the replace shortcut follows platform convention: Option+Cmd+F on macOS, Ctrl+H on Windows/Linux. Also reuses openEditorSearch instead of duplicating the open-and-focus logic. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Restores localhost/default host binding; the 127.0.0.1 override was a local-environment workaround unrelated to find & replace. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The custom icons read as "open in new window"; these are the standard Lucide glyphs, matching the icon set used across the app. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Adds Find & Replace functionality to the editor.
Features Added
Benefits
Screenshot
Closes #173
Summary by CodeRabbit
New Features
Bug Fixes
Chores