Add Find & Replace functionality with Replace and Replace All actions#180
Add Find & Replace functionality with Replace and Replace All actions#180Nivet2006 wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (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
Summary
Adds Find & Replace functionality to the editor.
Features Added
Benefits
Screenshot
Closes #173
Summary by CodeRabbit
New Features
Bug Fixes
Chores