Skip to content

Add inline find bar as an alternative to the floating find/replace panel#1642

Open
valsong wants to merge 1 commit intomacvim-dev:masterfrom
valsong:master
Open

Add inline find bar as an alternative to the floating find/replace panel#1642
valsong wants to merge 1 commit intomacvim-dev:masterfrom
valsong:master

Conversation

@valsong
Copy link
Copy Markdown

@valsong valsong commented Apr 16, 2026

Summary

Previously, Cmd+F opened a floating NSPanel (MMFindReplaceController). This PR introduces an optional inline find bar (MMFindBarView) that appears as an overlay anchored to the top-right corner of the text area, similar to the find bar in VS Code and other modern
editors.

The inline mode is off by default (preserving existing behaviour) and can be enabled via a new Find bar: Inline toggle in the General preferences pane.

  • Add MMFindBarView: a programmatic NSView overlay with find/replace fields, Ignore Case / Match Word checkboxes, Replace / Replace All / Previous / Next buttons, and an MMHoverButton close button styled to match the tab close button
  • The bar is freely draggable within the text-editing area and snaps to the top-right corner only on first show; subsequent Cmd+F presses preserve the user's dragged position
  • Window resize and tab-bar show/hide keep the bar in place via a delta-based repositioning algorithm
  • Add MMFindBarInlineKey user default and register it (default NO)
  • Add Find bar toggle to the General preferences pane
  • Route ShowFindReplaceDialogMsgID to the inline bar or the floating panel depending on the preference (MMVimController)
  • Add -sendFindBarAction:findString:replaceString:ignoreCase:matchWord: to MMWindowController to unify search message dispatch for both modes; fix IBAction tag-to-FRD-flags mapping (tag 2→flags 3, tag 3→flags 4)

Test plan

  • Build and run MacVim
  • Enable Find bar: Inline in General preferences
  • Press Cmd+F — inline bar appears in top-right corner of text area
  • Drag the bar to another position, press Cmd+F again — position is preserved
  • Add a new tab — bar moves down to follow the text area top edge
  • Resize the window — bar stays in place relative to text area
  • Verify Next / Previous / Replace / Replace All work correctly
  • Press Escape — bar closes and focus returns to the editor
  • Disable Find bar: Inline — Cmd+F opens the original floating panel
settings1 findbar1 settings2 findbar2

Previously, Cmd+F opened a floating NSPanel (MMFindReplaceController).
This commit introduces an optional inline find bar (MMFindBarView) that
appears as an overlay anchored to the top-right corner of the text area,
similar to the find bar in VS Code and other modern editors.

The inline mode is controlled by a new "Find bar: Inline" preference in
the General pane (off by default, preserving existing behaviour).

Changes:
- Add MMFindBarView: a programmatic NSView overlay with find/replace
  fields, Ignore Case / Match Word checkboxes, Replace / Replace All /
  Previous / Next buttons, and an MMHoverButton close button styled to
  match the tab close button
- The bar is freely draggable within the text-editing area and snaps to
  the top-right corner only on first show; subsequent Cmd+F presses
  preserve the user's dragged position
- Window resize and tab-bar show/hide keep the bar in place via a
  delta-based repositioning algorithm
- Add MMFindBarInlineKey user default and register it (default NO)
- Add "Find bar" toggle to the General preferences pane
- Route ShowFindReplaceDialogMsgID to the inline bar or the floating
  panel depending on the preference (MMVimController)
- Add -sendFindBarAction:findString:replaceString:ignoreCase:matchWord:
  to MMWindowController to unify search message dispatch for both modes;
  fix IBAction tag-to-FRD-flags mapping (tag 2→flags 3, tag 3→flags 4)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eirnym
Copy link
Copy Markdown
Contributor

eirnym commented Apr 16, 2026

I vote for that change. This solution is more clear what the context is in comparison to a floating window.

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.

2 participants