jupyterlab-contrib / jupyterlab-vim

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

Esc key does not exit insert mode in notebooks opened from file browser or launcher #94

Closed firai closed 11 months ago

firai commented 11 months ago

Description

After entering insert mode from a notebook opened from the file browser or launcher, pressing Esc does not exit out of insert mode. Instead, it fires a "Cannot execute key binding 'Escape': command 'documentsearch:end' is not enabled." warning (see console log at bottom).

If the notebook is already opened when the JL page is refreshed, Esc exits out of insert mode as expected. In this case, pressing Esc in normal mode fires the warning above, without apparent user-facing side effects.

Ctrl+] is able to exit insert mode as a workaround.

I'm wondering if this has something to do with #90... @krassowski, do you know if this is expected to resolve itself when JL 4.1 is released?

Context

Console log
Language pack 'English_United States' not valid! [jlab_core.0faecc546c73b7263d33.js:1:1441965](http://localhost:8888/static/lab/jlab_core.0faecc546c73b7263d33.js?v=0faecc546c73b7263d33)
Uncaught (in promise) Error: Editor not available
    modifyEditor http://localhost:8888/lab/extensions/@axlair/jupyterlab_vim/static/353.8b609c372dc07b2baac6.js?v=8b609c372dc07b2baac6:1
    updateLastActive http://localhost:8888/lab/extensions/@axlair/jupyterlab_vim/static/353.8b609c372dc07b2baac6.js?v=8b609c372dc07b2baac6:1
    x http://localhost:8888/lab/extensions/@axlair/jupyterlab_vim/static/353.8b609c372dc07b2baac6.js?v=8b609c372dc07b2baac6:1
    activate http://localhost:8888/lab/extensions/@axlair/jupyterlab_vim/static/353.8b609c372dc07b2baac6.js?v=8b609c372dc07b2baac6:1
    promise callback*activate http://localhost:8888/lab/extensions/@axlair/jupyterlab_vim/static/353.8b609c372dc07b2baac6.js?v=8b609c372dc07b2baac6:1
    promise http://localhost:8888/static/lab/jlab_core.0faecc546c73b7263d33.js?v=0faecc546c73b7263d33:1
    promise callback*activatePlugin http://localhost:8888/static/lab/jlab_core.0faecc546c73b7263d33.js?v=0faecc546c73b7263d33:1
    i http://localhost:8888/static/lab/jlab_core.0faecc546c73b7263d33.js?v=0faecc546c73b7263d33:1
    start http://localhost:8888/static/lab/jlab_core.0faecc546c73b7263d33.js?v=0faecc546c73b7263d33:1
    K http://localhost:8888/static/lab/812.b5f86ce00b402f3e2056.js?v=b5f86ce00b402f3e2056:1
    e http://localhost:8888/static/lab/main.2e96fbfd279ab7fd7ade.js?v=2e96fbfd279ab7fd7ade:1
    37559 http://localhost:8888/static/lab/main.2e96fbfd279ab7fd7ade.js?v=2e96fbfd279ab7fd7ade:1
    t http://localhost:8888/static/lab/main.2e96fbfd279ab7fd7ade.js?v=2e96fbfd279ab7fd7ade:1
     http://localhost:8888/static/lab/main.2e96fbfd279ab7fd7ade.js?v=2e96fbfd279ab7fd7ade:1
     http://localhost:8888/static/lab/main.2e96fbfd279ab7fd7ade.js?v=2e96fbfd279ab7fd7ade:1
[353.8b609c372dc07b2baac6.js:1:547](http://localhost:8888/lab/extensions/@axlair/jupyterlab_vim/static/353.8b609c372dc07b2baac6.js?v=8b609c372dc07b2baac6)
Cannot execute key binding 'Escape': command 'documentsearch:end' is not enabled. [jlab_core.0faecc546c73b7263d33.js:1:1608961](http://localhost:8888/static/lab/jlab_core.0faecc546c73b7263d33.js?v=0faecc546c73b7263d33)
krassowski commented 11 months ago

do you know if this is expected to resolve itself when JL 4.1 is released?

Yes, but the goal is to have this extension work without bugs until then so we need to fix it ;) As mentioned in #90 the search shortcut is problematic as it takes precedence. It is no longer the case in JupyterLab 4.1 alpha. We could try to backport a fix but it involves changing shortcuts and does not really belong in a patch release.

In #90 I worked around the issue for file editors by adding a shortcut with higher precedence (which relies on some lumino implementation detail and DOM hierarchy). Something like:

{
  "command": "vim:enter-normal-mode",
  "keys": ["Escape"],
  "selector": ".jp-Notebook"
},

for notebook may do. Can you confirm if this helps?

firai commented 11 months ago
{
  "command": "vim:enter-normal-mode",
  "keys": ["Escape"],
  "selector": ".jp-Notebook"
},

for notebook may do. Can you confirm if this helps?

Yes, this seems to work. Thanks for the quick response! Can you add a PR then?

firai commented 11 months ago

Upon further testing, it seems like at least some command mode shortcuts, i.e., those starting with Ctrl+O, seem to also be borked in version 4.0.0, presumably after #90 was merged. I don't know if whether it's related or a separate issue that I should open a separate ticket for.

krassowski commented 11 months ago

Can you confirm that https://github.com/jupyterlab-contrib/jupyterlab-vim/pull/95 fixes both issues?

firai commented 11 months ago

Yes. Thanks!

ianhi commented 11 months ago

Should be fixed in the latest release. and hopefully this release will also work on conda-forge as well

firai commented 9 months ago

Hi @ianhi, I think this can be unpinned now. What do you think?