marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
6.66k stars 232 forks source link

Escape is not respected before delay in vim's editing mode #657

Open peterwilton-ttam opened 8 months ago

peterwilton-ttam commented 8 months ago

Describe the bug

I find that Escape is not always respected when the vim keybindings are enabled and I am typing in vim's editor mode. When I hit Escape very soon after typing something, I have to wait a short while before hitting Escape again to make the editor leave vim's editing mode. If there's already been a short pause since the last keystroke, Escape works on first press. The delay is very short, so I am wondering whether this is just something inherent about the JS text editor.

I'm new to Marimo and loving it. Thanks for your work!

Environment

$ marimo env
{
  "marimo": "0.1.82",
  "OS": "Darwin",
  "OS Version": "23.1.0",
  "Processor": "arm",
  "Python Version": "3.11.6",
  "Binaries": {
    "Chrome": "120.0.6099.234",
    "Node": "v21.2.0"
  },
  "Requirements": {
    "black": "23.12.0",
    "click": "8.1.7",
    "jedi": "0.19.1",
    "pymdown-extensions": "10.7",
    "starlette": "0.36.1",
    "tomlkit": "0.12.3",
    "typing_extensions": "4.9.0",
    "uvicorn": "0.27.0"
  }
}

My browser is Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0. But I find this is also true on Linux and/or using Chrome.

Code to reproduce

N/A: text editor issue.

mscolnick commented 8 months ago

@peterwilton-ttam thanks for filing the bug. I am having trouble repro, but I don't use Vim often, so could be just me.

When you say Vim's editing mode, do you mean Insert or Command mode?

There is not delay coded into the editor or vim extension. The only thing I can think of is Esc being captured/intercepted. For example, if the code-complete is open, then Esc will close that first before moving back to Command mode.

peterwilton-ttam commented 8 months ago

Oops, I mean vim's Insert mode. And it seems you're right: when I disable code autocompletion the problem goes away. This gives me a workaround, thanks.

peterwilton-ttam commented 8 months ago

This is probably only possible because I have caps lock mapped to escape at the OS level. If I were reaching over to the physical escape key I think there would tend to be enough time lapsed that autocompletion would have enough time to figure out that it has nothing to complete and close on its own.

mscolnick commented 8 months ago

I will move this to lower priority, given the workaround. Let me know if it begins to bother between the tradeoff of code-autocomplete and the Vim esc race condition, and we can bring the priority back up.