jupyterlab-contrib / jupyterlab-vim

Vim notebook cell bindings for JupyterLab
https://jupyterlab-contrib.github.io/jupyterlab-vim.html
MIT License
691 stars 43 forks source link

Opening text editor after notebook causes normal mode j & k in cells to be stuck within a cell #103

Closed firai closed 1 year ago

firai commented 1 year ago

Description

If a file editor is opened after opening notebooks, when I switch back to a notebook, j and k in normal mode aren't able to move between cells if I enter normal mode directly in the first cell that has focus. That is, it appears to cause j and k to be unbound from moveByLinesOrCell. Escaping to command mode and moving to another cell appears to fix the binding.

Reproduce

  1. Open or create a notebook with multiple cells
  2. Open or create a file-editor-type document (text, Markdown or code)
  3. Switch back to the notebook
  4. Enter normal mode in the first cell that has focus
  5. Navigate to the edges of the cell with j or k and try to move beyond the edges

Expected behavior

Opening file editors should not affect the behavior in notebooks

Context

firai commented 1 year ago

By the way, I hit this while trying to develop a setting that would allow j and k to be remapped to gj and gk-type behavior but have the ability to cross cell boundaries. The proof of concept generally works for notebooks, but opening a file editor causes regular j and k to take over (at least until I move between cells in command mode in a notebook).

krassowski commented 1 year ago

We need to invoke modifyCell method after switching active widget of the shell (if the new widget is a notebook). For now we are only listening to cell changes. Should be easy to fix.

firai commented 1 year ago

Thanks for the quick response! I'm also hitting a quirk where j or k pressed at the bottom or top of file editors, respectively, moves the cursor to a notebook tab if the notebook was the last active tab (as opposed to another file editor). Does that sound like a related issue or should I open another issue for this?

ianhi commented 1 year ago

if the notebook was the last active tab (as opposed to another file editor). Does that sound like a related issue or should I open another issue for this?

I think that that is this oldish issue: https://github.com/jupyterlab-contrib/jupyterlab-vim/issues/15

firai commented 1 year ago

if the notebook was the last active tab (as opposed to another file editor). Does that sound like a related issue or should I open another issue for this?

I think that that is this oldish issue: #15

Thanks for the heads up! I didn't see that one. Good that I checked before opening another issue.