Skip to content
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

⌨️ Keyboard shortcut Alt-Arrow to move cells #2760

Merged
merged 4 commits into from Dec 18, 2023
Merged

Conversation

fonsp
Copy link
Owner

@fonsp fonsp commented Dec 18, 2023

You can now use Alt + Up/Down (or Option + Up/Down on Mac) to move cells in the notebook.

This was already the shortcut to move lines within a cell (just like VS Code). I found a nice way to make the shortcut work naturally for both actions:

  • If you selected one or more cells (with the click-drag action), use the shortcut to move cells.
  • If you are editing a single-line cell, use the shortcut to move the cell.
  • If you are editing a multiline cell, use the shortcut to move (selected) lines.
  • If you are editing a multiline cell and you selected all code (e.g. with Cmd + A), use the shortcut to move the cell.

All methods will auto-scroll (instant) to keep the cell in view.

Schermopname.2023-12-18.om.17.02.39.mov

@fonsp fonsp added frontend Concerning the HTML editor accessibility Accessibility improvements of the frontend, like screen reader support and internationalization labels Dec 18, 2023
Copy link
Contributor

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="move-cells-with-alt-arrow")
julia> using Pluto

@fonsp
Copy link
Owner Author

fonsp commented Dec 18, 2023

I had one weird issue when moving the cell from the CM (when everything is selected): moving up works fine, but moving down causes the CM to lose focus, so I had to manually refocus the cell after moving. It looks janky and cm_forced_focused cells dont fully work. Annoying!

Not sure why it happens, the preact key is working properly: the cell input is not being regenerated, it just loses focus.

EDIT: this was caused by preactjs/preact#4235

@fonsp fonsp merged commit 9f287b4 into main Dec 18, 2023
3 checks passed
@fonsp fonsp deleted the move-cells-with-alt-arrow branch December 18, 2023 17:32
@fonsp
Copy link
Owner Author

fonsp commented Dec 19, 2023

Part of #65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Accessibility improvements of the frontend, like screen reader support and internationalization frontend Concerning the HTML editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant