cmux/Sources/Panels
atani 3a5bd8494c
fix: avoid NSTextView tracking loop in omnibar mouseDown (#928)
* fix: avoid NSTextView tracking loop in omnibar mouseDown (#917)

Replace the synthetic mouseUp timeout workaround with direct cursor
positioning via NSTextView.characterIndexForInsertion(at:). The previous
approach posted a fake mouseUp event via NSApp.postEvent after 3 seconds,
but the NSTextView tracking loop does not always dequeue events from the
application event queue when stuck in an infinite
NSTextLayoutManager.enumerateTextLayoutFragments cycle, so the hang
persisted.

The new approach bypasses super.mouseDown entirely when the field editor
is already active, positioning the cursor (or extending the selection
with Shift+click) without entering the tracking loop. Drag-to-select is
not supported in this code path, but for a single-line omnibar this is
an acceptable trade-off.

* fix: handle double-click, UTF-16 length, and shift-click anchor

Address review feedback:

- Forward double/triple-click events to editor.mouseDown(with:) to
  preserve word and line selection without entering NSTextField's
  tracking loop
- Use (editor.string as NSString).length instead of String.count for
  NSRange clamping (NSRange uses UTF-16 indices)
- Track shift-click anchor independently via shiftClickAnchor property
  to correctly handle bidirectional selection extension

* fix: reset shiftClickAnchor on keyDown to prevent stale anchor

Clear the shift-click selection anchor whenever a key is pressed, so
that keyboard navigation (arrow keys, Shift+arrow, Home/End, etc.)
properly invalidates the mouse-originated anchor. A subsequent
Shift+click will then use the current selection position as anchor
instead of a stale value from a prior mouse interaction.

* fix: reset shiftClickAnchor in performKeyEquivalent and on re-focus

Key equivalents (Cmd+A, Cmd+V, etc.) bypass keyDown and go through
performKeyEquivalent, so the anchor must also be cleared there.
Similarly, re-focusing the field (currentEditor() == nil path) should
reset the anchor since selectAll changes the selection state.
2026-03-05 02:31:23 -08:00
..
BrowserPanel.swift Fix terminal link opens to stay in source workspace (#912) 2026-03-04 19:21:45 -08:00
BrowserPanelView.swift fix: avoid NSTextView tracking loop in omnibar mouseDown (#928) 2026-03-05 02:31:23 -08:00
CmuxWebView.swift feat: add Japanese localization with String Catalog (#819) 2026-03-04 14:58:28 -08:00
MarkdownPanel.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
MarkdownPanelView.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
Panel.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
PanelContentView.swift feat: add markdown viewer panel with live file watching (#883) 2026-03-04 17:48:28 -08:00
TerminalPanel.swift Fix orphaned child processes when closing workspace tabs (#889) 2026-03-04 20:00:35 -08:00
TerminalPanelView.swift Fix terminal Cmd+F overlay layering and add regression guardrails 2026-02-22 15:25:30 -08:00