Commit graph

1 commit

Author SHA1 Message Date
易良
c1bc6b202e
feat(web-shell): add Option+Enter and Cmd+Enter newline shortcuts (#5005)
* feat(web-shell): add Option+Enter and Cmd+Enter newline shortcuts

The web terminal input only bound Shift+Enter and Ctrl+J for inserting a
newline. Option/Alt+Enter — common terminal muscle memory — did nothing,
and Cmd+Enter (bound in the CLI TUI's NEWLINE command) was missing too.

Add `Alt-Enter` and `Mod-Enter` bindings (Mod resolves to Cmd on macOS,
Ctrl elsewhere, mirroring the TUI's command/ctrl+return bindings), and
refactor the duplicated newline handler into a shared `insertNewline`.
The shortcuts panel label is now platform-aware (opt+enter on macOS,
alt+enter otherwise).

Adds a regression test that mounts a real CodeMirror EditorView and
dispatches real keydown events to lock the new key resolutions.

* fix(web-shell): address review — show Mod+Enter in shortcuts panel, tighten Mod keymap test

- ShortcutsPanel: the newline label omitted the Mod+Enter binding; now shows
  cmd+enter (macOS) / ctrl+enter (elsewhere) alongside opt/alt+enter so the
  panel matches the actual keymap.
- Editor.keymap.test: the Mod+Enter case dispatched both metaKey and ctrlKey,
  so the platform-mismatched press was a silent no-op and the assertion passed
  regardless. Dispatch only the platform-correct modifier and assert exactly
  '\n', so breaking Ctrl+Enter on non-mac (or Cmd+Enter on mac) now fails.
2026-06-12 13:07:56 +08:00