Skip to content

Replace the search indicator with a real editable field - #85

Closed
alvst wants to merge 1 commit into
momenbasel:mainfrom
alvst:alvie/pr-native-search
Closed

alvst wants to merge 1 commit into
momenbasel:mainfrom
alvst:alvie/pr-native-search

Conversation

@alvst

@alvst alvst commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

The search UI was a synthetic pill assembled from captured keystrokes: append-only, with no cursor, no click-to-edit, no selection, and no IME. This replaces it with a real NSTextField edited through the normal AppKit responder chain.

What changed

  • NativeBarSearchField is a real text field: cursor, click-to-edit, text selection, ⌘A/⌘X/⌘C/⌘V, and IME/dead-key input all work.
  • The field stays mounted even in its compact zero-width state, so the bar's key monitor can focus it synchronously and the very first typed character isn't lost.
  • BarInputMode tracks whether the field or the clip strip owns focus, so the key monitor and the field agree on who handles a given key instead of probing the responder chain from every call site.

Screenshots

Before:
00-baseline screenshots bar.png

After:
04-native-search screenshots after.png

Notes for review

  • The first-responder guard that keeps bar shortcuts alive while typing is intact — verified that ⌘-shortcuts still reach the bar with the field focused.
  • Related: alvie/pr-27-space-preview-with-search exists because this branch and alvie/pr-quicklook interact — a focused field would otherwise swallow Space-to-preview. That's fixed in its own PR, not here; nothing in this branch regresses on its own.
  • Out of scope: no search scoping, history, or regex.

This feature should be bundled into v2.

Part of #80.

The previous search UI was a synthetic pill built from captured
keystrokes — appended-only, no cursor, no click-to-edit, no text
selection or IME support. NativeBarSearchField is a real NSTextField
edited through the normal AppKit responder chain (kept mounted even in
its compact zero-width state, so the bar's key monitor can focus it
synchronously and hand off the very first keystroke without losing it).

BarInputMode tracks whether focus belongs to the field or the clip
strip, so the monitor and the field agree on who owns a given key
without probing the first-responder chain from every call site.
@momenbasel

Copy link
Copy Markdown
Owner

Landed as d106242 through #104 with a follow-up (b66d10a). The field took every key while it had focus: Return resigned it and handed focus back to the cards instead of pasting, so open, type, Return needed two Returns; Command-1 to Command-9 went to the field editor, which has no binding for them; and Up, Down, Left and Right moved a caret inside a one-line query instead of the selection. Return now pastes the selected clip from the field's delegate, the quick-paste digits are handled before the field takes the event, and the delegate routes Up and Down, plus Left and Right once the caret sits at the matching end of the query, to the strip's selection. A hide while the field was focused (Escape on an empty query, the hotkey, a click outside) also left it first responder of the ordered-out panel, so the next presentation came up in search mode; showBar resigns the field and resets the input mode first. Thanks @alvst.

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