vscode-neovim: infinite file opening loop
Here is my System info:
Operating System: Garuda Linux
KDE Plasma Version: 5.21.5
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2
Kernel Version: 5.12.1-zen2-1-zen
OS Type: 64-bit
Graphics Platform: X11
Processors: 8 × 11th Gen Intel® Core™ i7-1185G7 @ 3.00GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
This happened first to me when I tried ctrl+shift+p
to open up the settings.json. I wasn’t able to reproduce this in mac os and I think it just started happening recently. Anyway, the jist of it is that it just continuously opens new files. I get two errors in the console:
ERR nvim_win_close: Invalid window id: 1051: Error: Error making request to nvim_win_close
at o.request (/home/joshua/.vscode-oss/extensions/asvetliakov.vscode-neovim-0.0.78/dist/extension.js:1:15853)
at Timeout._onTimeout (/home/joshua/.vscode-oss/extensions/asvetliakov.vscode-neovim-0.0.78/dist/extension.js:3:101219)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
and
ERR nvim_win_get_cursor: Invalid window id: 1060: Error: Error making request to nvim_win_get_cursor
at o.request (/home/joshua/.vscode-oss/extensions/asvetliakov.vscode-neovim-0.0.78/dist/extension.js:1:15853)
at he.<anonymous> (/home/joshua/.vscode-oss/extensions/asvetliakov.vscode-neovim-0.0.78/dist/extension.js:3:100678)
at Generator.next (<anonymous>)
at /home/joshua/.vscode-oss/extensions/asvetliakov.vscode-neovim-0.0.78/dist/extension.js:3:88882
at new Promise (<anonymous>)
at ce (/home/joshua/.vscode-oss/extensions/asvetliakov.vscode-neovim-0.0.78/dist/extension.js:3:88627)
at Timeout._onTimeout (/home/joshua/.vscode-oss/extensions/asvetliakov.vscode-neovim-0.0.78/dist/extension.js:3:100617)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
But mostly the first window close error. I don’t know why this causes continuous new windows to open up, but when I disable the extension it stops it.
You can see what it looks like here:
As a side note, I thought maybe I could fix this myself and put in a pull request, but I don’t have a whole lot of time and I was having trouble getting into debugging the extension. I couldn’t really get it activated. If there’s a slack channel that can help me get up and running I can try to fix it myself.
Let me know! Thanks!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 66
- Comments: 59 (17 by maintainers)
Commits related to this issue
- Revert "api/window: use the "noblock" variants in nvim_win_set_buf" This reverts commit 1def3d1542d6a65f057e743faea39a760b50db87. Plugins may depend on catching the following events when creating wi... — committed to janlazo/neovim by janlazo 3 years ago
- Community fix for #632 — committed to vscode-neovim/vscode-neovim by asvetliakov 3 years ago
- Revert "api/window: use the "noblock" variants in nvim_win_set_buf" This reverts commit 1def3d1542d6a65f057e743faea39a760b50db87. Plugins may depend on catching the following events when creating wi... — committed to last-partizan/neovim by janlazo 3 years ago
This command writes to a file named
extensions.js
, but the correct file isextension.js
, which means the following is the correct command:How did the original comment get 6 positive reactions (at the time of writing) while having a typo, and thus not working, is beyond me. Nice solution overall though.
Released 0.0.79 with the fix. Thanks @seandewar !
I applied @seandewar’s patch to the latest release of the plugin, and it works fine as far as I can tell.
To use the plugin without downgrading neovim:
curl -L https://gist.github.com/kidonng/1f70b2e3de50b519483f6c79dd3d82e2/raw/6b865cec34f78475dc50b208b30563d337427543/extension.js > ~/.vscode/extensions/asvetliakov.vscode-neovim-0.0.78/dist/extension.js
(Or grab the file from https://gist.github.com/kidonng/1f70b2e3de50b519483f6c79dd3d82e2 and replace
dist/extension.js
under extension directory manually)Temporary fix:
Point to
<your home directory>/nvim/bin/nvim
https://github.com/neovim/neovim/pull/13664 is cause
@seandewar will it disable autocmd events for buffers? we rely on them for some things - external buffers (like
:help
) and jumping.okay i’ve got repro now
My init.vim is empty now and it still seems to be acting up. I will see if there is something I am missing.
Welcome to the open source.
I’ll push the update soon, sorry for taking it too long and any inconvenience it caused
Glad to see my fix appears to be working. 🎉 Thanks @kidonng and @eyalch for making it easily installable.
I’m happy to open a PR if @asvetliakov is OK with this.
Just to note, if the problematic Nvim patch does get reverted, keeping the fix in shouldn’t cause any issues. I would still recommend reverting the fix after some time once it’s no longer required, though.
I can imagine that in most cases (unless there’s some weird event nesting going on) if
eventignore
is set only for the duration ofopenWindow()
, it can be used to disable the problematic events fired bynvim_open_win()
(andnvim_win_set_buf()
) only, which may be used to replicate the behaviour before the patch.You’ll need to remember to restore
eventignore
after eachopenWindow()
call though.The main reason this patch is causing issues for people is that
BufWinEnter
,BufEnter
andBufLeave
can now fire when they previously couldn’t, among others (BufWinLeave
may also cause problems in some other plugins).For many people, it might be enough to
set eventignore=BufWinEnter,BufEnter,BufLeave
beforeopenWindow()
.Thought I’d experiment a bit with this idea. After making the following changes I wasn’t able to reproduce the issue anymore:
This didn’t seem to break
:help
or jumping or anything obvious (might be wrong – I don’t use VSC 🤷). Can somebody test this?Update: A decision was made to revert the patch within a month if there’s no fix upstream, so a workaround may not be necessary soon! 🎉
This is the first time I installed this extension, but due to this issue, it is not useable. I hope this bug gets fixed soon.
git diff view is also broken too. sometimes also happens with ordinary files too
Thanks! Happy to have helped. 🎉
Just a heads up that I’m working on a proper fix upstream at https://github.com/neovim/neovim/pull/14659 (Edit: this has since been merged) that may add a
noautocmd
option tonvim_open_win
to restore the old behaviour.The
eventignore
fix will continue to work after that PR is merged so there’s no rush to update things (it may also take a while foropenWindow
in https://github.com/neovim/node-client to be updated with the new option unless someone volunteers to do it).@seandewar Awesome, thank you. Subscribed for
noautocmd
PR. I also might be revisiting window management later (by dropping support of external buffers)I appreciate your help Alexey! This plugin literally is what makes vscode a viable editor for me.
On Fri, May 28, 2021 at 9:00 AM Alexey Svetliakov @.***> wrote:
–
Fabio Miranda Costa (he/him/his) twitter: @fabiomiranda https://twitter.com/fabiomiranda github: fabiomcosta https://github.com/fabiomcosta/ linkedin: fabiomirandacosta https://www.linkedin.com/in/fabiomirandacosta/
Is it possible that this issue has returned? I’m observing a similar behaviour. An untitled copy of the current file opens at Vscode’s startup. And multiple start to appear when I run a python script on an interactive window. Curiously this only happens when a init.vim file is present. Even a fully commented out init.vim triggers the issue. Deleting or renaming the default init.vim solves the problem.
My specific setup consists on: OS: Windows 10 Visual Studio Code: 1.78.2 Neovim: 0.9.0 or 0.10.0-dev-382-gebb10d624 (I have tried both in case the issue was solved on nightly builds)
Could be something related to Python or Jupyter extensions? I’m working with python scripts via the Microsoft plugins. The extension is great, but dealing with the tab clutter becomes a bit tiresome after a while…
One reason for not reverting immediately is at https://github.com/neovim/neovim/pull/14531#issuecomment-838119219.
Breaking changes are to be expected in 0.5, as it is the currently unreleased version.
@seandewar @asvetliakov you people are saviours. Thanks a lot!!
can confirm that the fix is working with vscodium also, thank you.
@eyalch Typo fixed, thanks for spotting it!
Hello, I’m also a new user, and I would like to know if the workaround will be implemented in the VScode plugin and released soon? I will apply the patch on my end, but I suggest it be released asap as well. Thanks.
Also workaround to break the loop: Ctrl-N few times to create new tab(s) then
qall!
I think I’ll try to figure out what plugins I need to not initialize, since I do still use some of them, even in visual studio code.