Skip to content

fix(hotkeys): make copy line up/down hotkeys editable#10241

Open
Abdulrehman-PIAIC80387 wants to merge 1 commit into
marimo-team:mainfrom
Abdulrehman-PIAIC80387:fix/editable-copy-line-hotkeys-7056
Open

fix(hotkeys): make copy line up/down hotkeys editable#10241
Abdulrehman-PIAIC80387 wants to merge 1 commit into
marimo-team:mainfrom
Abdulrehman-PIAIC80387:fix/editable-copy-line-hotkeys-7056

Conversation

@Abdulrehman-PIAIC80387

Copy link
Copy Markdown

This pull request was authored by a coding agent.

📝 Summary

Closes #7056

Copy line(s) up / Copy line(s) down appear in the Keyboard Shortcuts panel but are marked editable: false, so the panel advertises two rows it silently refuses to customize.

That flag was a deliberate stopgap in #6843, which said as much:

since right now we don't override it in the codemirror settings, this needs to be set to not editable

The commands are served by CodeMirror's built-in defaultKeymap, which hardcodes Shift-Alt-Arrow, so marimo's hotkey config never reached them. @mscolnick invited a follow-up FR for this in #6338 ("we can look into making it editable. mind filing a FR?"), which became #7056.

🔍 Description of Changes

Uses the override mechanism already established in keymaps.ts for toggleComment / toggleBlockComment — no new machinery:

  • frontend/src/core/codemirror/keymaps/keymaps.ts — add copyLineUp/copyLineDown to OVERRIDDEN_COMMANDS (filters the hardcoded bindings out of the default keymap), then re-bind them in overrideKeymap() via keymap.getHotkey(...) so they follow user config.
  • frontend/src/core/hotkeys/hotkeys.ts — remove editable: false from both entries.

Default keybindings are unchanged — only the ability to reconfigure them is added. Applies to both the default and vim presets, since keymapBundle installs overrideKeymap for each.

Both directions are included because the issue asks for both and they share one mechanism.

🧪 Testing

  • make fe-check — clean
  • pnpm vitest run src/core/codemirror src/core/hotkeys — 660 passed, 1 skipped (47 files)
  • The keymap collision snapshot in setup.test.ts is unchanged at 18 duplicates — no new conflicts.

The pre-existing generic assertions in keymaps.test.ts (overrideKeymap().length === OVERRIDDEN_COMMANDS.size, and no overridden command surviving in the filtered keymap) picked up the two new commands automatically.

Added a test asserting an override to Ctrl-D actually reaches the keymap — the exact rebinding @mullimanko asked for. It guards the user-facing behavior rather than the plumbing: reverting the overrideKeymap half while leaving editable on would still pass the generic tests, but fails this one.

⚠️ Note on readiness

Opening as a draft. This issue carries neither ready nor needs discussion, and CONTRIBUTING says to treat unlabeled issues as needing discussion — so please read this as a concrete proposal awaiting your go-ahead, not a review request. Happy to close it if you'd prefer this waited or went a different way.

Demo media for the settings-panel change is still to come before this would be marked ready.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue — see document shortcut to "copy line down" in the shortcuts page in the marimo editor #6338 where a maintainer invited this FR; awaiting explicit go-ahead here.
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable — no public API or docs change; the shortcut is self-documenting in the panel.
  • Tests have been added for the changes made.

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jul 20, 2026 10:14am

Request Review

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy line(s) up/down were listed in the Keyboard Shortcuts panel but
marked `editable: false`, because they were served by CodeMirror's
built-in `defaultKeymap` and so never consulted marimo's hotkey config.

Route both commands through the existing override mechanism already used
by `toggleComment`/`toggleBlockComment`: add them to OVERRIDDEN_COMMANDS
so the hardcoded bindings are filtered out of the default keymap, then
re-bind them in `overrideKeymap` using the configured hotkey. Default
keybindings are unchanged.

Closes marimo-team#7056
@Abdulrehman-PIAIC80387
Abdulrehman-PIAIC80387 force-pushed the fix/editable-copy-line-hotkeys-7056 branch from 7c1ea93 to f8e6a53 Compare July 20, 2026 10:07
@Abdulrehman-PIAIC80387

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@Abdulrehman-PIAIC80387

Copy link
Copy Markdown
Author

recheck

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables user customization of the editor hotkeys for CodeMirror’s built-in “copy line up/down” commands by filtering their hardcoded default bindings and re-binding them through marimo’s hotkey provider, and by marking these actions as editable in the shortcuts UI.

Changes:

  • Remove the editable: false restriction for cell.copyLineUp / cell.copyLineDown so they can be customized in the Keyboard Shortcuts panel.
  • Override CodeMirror’s defaultKeymap bindings for copyLineUp / copyLineDown and re-bind them using keymap.getHotkey(...) so user overrides take effect.
  • Add a focused unit test to assert that user overrides (e.g., Ctrl-d) propagate into the resulting CodeMirror keymap bindings.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
frontend/src/core/hotkeys/hotkeys.ts Makes “Copy line(s) up/down” editable by removing the explicit non-editable flags.
frontend/src/core/codemirror/keymaps/keymaps.ts Filters out CodeMirror’s hardcoded bindings for copyLineUp/down and re-binds them via marimo’s configured hotkeys.
frontend/src/core/codemirror/keymaps/tests/keymaps.test.ts Adds a regression test ensuring hotkey overrides actually reach the CodeMirror keymap for copyLineUp/down.

Comment on lines 255 to 259
"cell.copyLineUp": {
name: "Copy line(s) up",
group: "Editing",
key: "Alt-Shift-ArrowUp",
editable: false,
},
@kirangadhave

Copy link
Copy Markdown
Member

@Abdulrehman-PIAIC80387 Can you please attach a demo video. I'll be happy to approve after that

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.

Make "copy line down" hotkey in the shortcuts page of the marimo editor editable

3 participants