-
Notifications
You must be signed in to change notification settings - Fork 860
Also allow Ctrl as modifier key on macOS
#7608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
d12fde2 to
95f6bd9
Compare
Does it make sense to just map this keyboard shortcut specifically? Instead of duplicating all This is a good starting point to see if there are potential conflicts: https://github.com/search?q=org%3Acodemirror+language%3ATypeScript+Ctrl&type=code |
I believe there are more mappings beyond running cells (e.g., actions like split cell), but I see the conflict now with others beyond that (builtin to codemirror). Maybe the right idea would be to expand all our cell-specific keymaps? cc: @akshayka |
|
I like the idea of scoping to cell-specific if that does not introduce conflicts |
On macOS, users coming from Jupyter and Colab may expect `Ctrl-Enter` to run cells, since those tools use `Ctrl` as the modifier key regardless of platform. Previously, only `Cmd-Enter` worked in marimo on macOS. There are two separate systems handling keyboard shortcuts in marimo: 1. Event handlers that use `parseShortcut()` to match keyboard events against shortcut strings. These check event properties like `metaKey` and `ctrlKey` directly. 2. CodeMirror's keymap system, which has its own string-based key parsing. When we pass `Cmd-Enter` to CodeMirror, it only matches the Command key. The fix addresses both: `parseShortcut()` now normalizes "cmd" to "mod" (which accepts either modifier), and `withCtrlEquivalents()` duplicates `Cmd` keybindings with `Ctrl` variants for CodeMirror. The cell editor keymaps use this wrapper so `Ctrl-Enter` runs cells just like `Cmd-Enter`.
The previous implementation added `withCtrlEquivalents()` which duplicated all Cmd-based keybindings to also accept Ctrl on macOS. This was too broad and risked conflicts with CodeMirror's built-in Ctrl shortcuts (Ctrl-D for selection, Ctrl-K for line operations, etc.). The fix narrows the scope: only run-related cell actions (`cell.run` and `cell.runAndNewAbove`) get `Ctrl` equivalents. These are the shortcuts that Jupyter and Colab users expect to work with Ctrl-Enter. Other cell keymaps like format, hide code, and focus navigation remain Cmd-only.
95f6bd9 to
80da1de
Compare
Rename `withCtrlEquivalent` to `duplicateWithCtrlModifier` and skip duplication when the binding already contains Ctrl. Adds test coverage.
|
This should be ready to go i think. |
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.18.5-dev171 |
On macOS, users coming from Jupyter and Colab may expect
Ctrl-Enterto run cells, since those tools useCtrlas the modifier key regardless of platform. Previously, onlyCmd-Enterworked in marimo on macOS.There are two separate systems handling keyboard shortcuts in marimo:
Event handlers that use
parseShortcut()to match keyboard events against shortcut strings. These check event properties likemetaKeyandctrlKeydirectly.CodeMirror's keymap system, which has its own string-based key parsing. When we passCmd-Enterto CodeMirror, it only matches the Command key.The previous implementation added
withCtrlEquivalents()which duplicated all Cmd-based keybindings to also accept Ctrl on macOS. This was too broad and risked conflicts with CodeMirror's built-in Ctrl shortcuts (Ctrl-D for selection, Ctrl-K for line operations, etc.).The fix narrows the scope: only run-related cell actions (
cell.runandcell.runAndNewAbove) getCtrlequivalents. These are the shortcuts that Jupyter and Colab users expect to work with Ctrl-Enter. Other cell keymaps like format, hide code, and focus navigation remainCmd-only.