zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
45.73k stars 2.52k forks source link

VIM mode stops working after opening another zed instance in parallel #14547

Open liona24 opened 1 month ago

liona24 commented 1 month ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I usually open multiple instances of zed for different workspace folders. I open following instances from terminal using zed -n path/to/dir. I have vim mode enabled in the existing instance. Now either of two things happen (usually): 1) Vim mode stops working in the existing instance 2) Vim mode is not enabled / is not working in the new instance

Sometimes it works, but if I keep opening I will see this happening eventually. Additionally, it is not consistent as well. If I switch the zed windows, sometimes it starts working again in one instance, but starts to fail in the other, or it stops working in both, etc.

I am not sure what to look for in the logs, there seems to be nothing related to key, vi

Environment

Zed: v0.143.7 (Zed) OS: Linux Wayland fedora 40 Memory: 30.9 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

No response

notpeter commented 1 month ago

Can you describe further what happens when vim mode stops working? What's broken / what are you trying to do, but can't, etc. Is there anything which proceeds the failure?

Next time could you also try toggling off/on vim mode (cmd+shift+p, toggle vim mode). I don't expect it necessarily help, but worth a shot.

liona24 commented 1 month ago

Usually I am stuck in insert mode (or vim is completely disabled I cannot tell the difference?), i.e. cannot switch back to normal mode, but the usual key input seems to work fine, meaning I can type and navigate via arrow keys. Sometimes I am stuck in normal mode and then no keys are accepted, i.e. no navigation via hjkl, cannot enter insert mode etc.

I tried issuing commands via cmd+shift+p as suggested. I did not find toggle vim mode so I am assuming I am still in vim mode. I could manually switch modes with that, f.e. issue vim: insert after which would get me out of normal mode in a stuck instance. This also recovered the instance pretty decently it seems. It however immediately killed the "working state" in the other instance.

notpeter commented 1 month ago

toggle vim mode should always be there (whether you are in vim or normal non-modal editing mode).

Screenshot 2024-07-16 at 12 19 22

If you determine any common patterns in the actions or editor content that results in the funky VIM state please share, but I'm glad there's a partial workaround (triggering a vim mode change via command palette) in the meantime.

liona24 commented 1 month ago

Found the toggle action now. It will disable vim in all open instances. Toggling it again will enable it in the currently focused instance and will cause the "bad" mode of operation in the other instance.

Currently this triggers every time. I do this:

mkdir /tmp/foo
touch /tmp/foo/foo.txt
mkdir /tmp/bar
touch /tmp/bar/bar.txt

zed /tmp/bar
zed -n /tmp/foo

Then opening the files foo.txt and bar.txt surely causes one of them to not work. Can you reproduce this by any chance?

I cannot really see anything that would be helpful in the logs, can I add verbosity somehow?

ConradIrwin commented 1 month ago

It sounds like focus events are not firing correctly between multiple windows.

Currently vim mode maintains an idea of which editor is active, and relies on window focus to switch between them.

liouk commented 4 weeks ago

I have the same issue on linux; env: