feat(editor): add find and replace to the search bar#911
Draft
Gimics wants to merge 2 commits into
Draft
Conversation
The editor search bar could only find, not replace. This adds replace, replace-all, and case / whole-word / regex toggles by driving CodeMirror's existing search state, so no new dependency is introduced. - SearchInline gains an expandable replace row and modifier toggles for editor targets; terminal and git-history search are unchanged. - EditorPaneHandle.setQuery carries the modifiers + replacement, and adds replaceNext / replaceAll. - Cmd/Ctrl+H opens find & replace, gated to editor focus so Ctrl+H stays backspace (^H) in the terminal. - Selecting text then pressing Cmd/Ctrl+F or +H prefills the query. - CodeMirror's built-in search panel keymap is disabled so the header bar is the single find/replace surface.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
The search bar focuses find for the editor and git history too, not just the terminal, so 'Find in terminal' was already inaccurate before the find-and-replace work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds find & replace to the editor's search bar. For editor tabs the bar now has case-sensitive, whole-word, and regex toggles plus an expandable replace row (Replace / Replace All).
Cmd/Ctrl+Hopens it directly, and selecting text beforeCmd/Ctrl+ForCmd/Ctrl+Hprefills the query. Terminal and git-history search are unchanged.Why
The search bar could only find in the editor — there was no way to replace text without leaving the app. The project-wide search work (#688, closes #128) shipped read-only and explicitly listed find-and-replace as out of scope, leaving the single-file editor case unaddressed.
Reuses CodeMirror's existing
@codemirror/searchstate, so it adds no new dependency. Scope is deliberately single-file editor find/replace — not IDE-scale project-wide search.How
SearchInlinerenders modifier toggles + an expandable replace row foreditortargets only;terminal/git-historypaths are untouched. Search application is centralized in one effect.EditorPaneHandle.setQuery(q, opts)carries the modifiers + replacement into the CodeMirrorSearchQuery, and addsreplaceNext/replaceAll. A small dedup ref stops the selection jumping while you type in the replace field.search.replaceshortcut =Cmd/Ctrl+H, gated inshortcutsDisabledto editor focus soCtrl+Hstays backspace (^H) in the terminal.getSelection()(editor + terminal).basicSetup.searchKeymapis disabled so CodeMirror's built-in panel no longer competes with the header bar — one find/replace surface.Cmd/Ctrl+Fshortcut from "Find in terminal" to "Find" — it already focused search for the editor and git-history views too, so the old label was inaccurate even before this change.Testing
pnpm exec tsc --noEmitcleansrc-tauri/) — N/A, no Rust changes#[tauri::command]signature) — N/Apnpm tauri devManual flows exercised in
pnpm tauri dev:Ctrl+F/Ctrl+Hfocus the bar; toggles (case / word / regex) update matches live;Enter/Shift+Entercycle.Ctrl+Hinside a focused terminal still deletes a character (backspace) — the binding is not hijacked there.Ctrl+F/Ctrl+H→ the query is prefilled from the selection.pnpm test: 438 pass. (Two pre-existingeager-budget.test.tsfailures onmainare a parse error unrelated to this change.)Screenshots
Notes for reviewer
Ctrl+Fnow always routes to the header search bar; CodeMirror's built-in search panel keymap is disabled. Flagging since it changes an existing interaction.@codemirror/search.