Skip to content

feat(editor): add find and replace to the search bar#911

Draft
Gimics wants to merge 2 commits into
crynta:mainfrom
Gimics:feat/editor-find-replace
Draft

feat(editor): add find and replace to the search bar#911
Gimics wants to merge 2 commits into
crynta:mainfrom
Gimics:feat/editor-find-replace

Conversation

@Gimics

@Gimics Gimics commented Jul 1, 2026

Copy link
Copy Markdown

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+H opens it directly, and selecting text before Cmd/Ctrl+F or Cmd/Ctrl+H prefills 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/search state, so it adds no new dependency. Scope is deliberately single-file editor find/replace — not IDE-scale project-wide search.

How

  • SearchInline renders modifier toggles + an expandable replace row for editor targets only; terminal / git-history paths are untouched. Search application is centralized in one effect.
  • EditorPaneHandle.setQuery(q, opts) carries the modifiers + replacement into the CodeMirror SearchQuery, and adds replaceNext / replaceAll. A small dedup ref stops the selection jumping while you type in the replace field.
  • New search.replace shortcut = Cmd/Ctrl+H, gated in shortcutsDisabled to editor focus so Ctrl+H stays backspace (^H) in the terminal.
  • Selection prefill uses the existing getSelection() (editor + terminal).
  • basicSetup.searchKeymap is disabled so CodeMirror's built-in panel no longer competes with the header bar — one find/replace surface.
  • Relabels the Cmd/Ctrl+F shortcut 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 --noEmit clean
  • Manual smoke-test of the affected feature
  • (If you touched src-tauri/) — N/A, no Rust changes
  • (If you changed a #[tauri::command] signature) — N/A
  • (If UI) tested in pnpm tauri dev
  • Platforms tested: Windows
  • Shells tested (if relevant): N/A

Manual flows exercised in pnpm tauri dev:

  • Ctrl+F / Ctrl+H focus the bar; toggles (case / word / regex) update matches live; Enter / Shift+Enter cycle.
  • Replace and Replace All modify the buffer; typing in the replace field does not jump the selection.
  • Ctrl+H inside a focused terminal still deletes a character (backspace) — the binding is not hijacked there.
  • Select text, then Ctrl+F / Ctrl+H → the query is prefilled from the selection.

pnpm test: 438 pass. (Two pre-existing eager-budget.test.ts failures on main are a parse error unrelated to this change.)

Screenshots

image

Notes for reviewer

  • Default-behavior change: in an editor, Ctrl+F now always routes to the header search bar; CodeMirror's built-in search panel keymap is disabled. Flagging since it changes an existing interaction.
  • No new dependencies — reuses @codemirror/search.
  • Opened as a draft for direction/alignment feedback before polishing (per CONTRIBUTING's "open a draft PR early"). Happy to adjust scope.

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.
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fa92988f-c41a-4ad5-828d-22a0240f8aa8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

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.
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.

Project-wide content search panel (Cmd+Shift+F)

1 participant