fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.91k stars 284 forks source link

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

Closed fonsp closed 7 months ago

fonsp commented 7 months ago

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:

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

https://github.com/fonsp/Pluto.jl/assets/6933510/96e120bb-80e2-4b72-92bc-861b76fe2656

github-actions[bot] commented 7 months ago

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 commented 7 months ago

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 https://github.com/preactjs/preact/issues/4235

fonsp commented 6 months ago

Part of #65