Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent from run window functions on invalid window ID #235

Closed
przepompownia opened this issue Nov 19, 2022 · 1 comment · Fixed by #639
Closed

Prevent from run window functions on invalid window ID #235

przepompownia opened this issue Nov 19, 2022 · 1 comment · Fixed by #639
Labels
bug Something isn't working

Comments

@przepompownia
Copy link

przepompownia commented Nov 19, 2022

Describe the bug

noice-invalid-window.mp4

Which version of Neovim are you using?
Upstream c011747b5fc33eb7d9955c21d85085131ffaac0d merged into fix_multigrid_lua_ui_attach (neovim/neovim#21080), fresh master nvim-qt in this case.

To Reproduce
Hi @folke
I know, it would be ideal to provide minimal init.lua but while I can assume if we know the solution (or at least workaround) then the time seems to be worth something better. I hope that those details are enough at the moment.

In practice, looking to recent changes in Neovim, I decided to learn some coroutine basics, analyze the example from :h luaref-coroutine and run it through the DAP adapter (using https://github.com/jbyuki/one-small-step-for-vimkind). The second instance (not shown on the screencast) used to run luafile with the example crashed after third or fourth time of running the script.

Expected Behavior
In https://github.com/folke/noice.nvim/blob/main/lua/noice/util/init.lua#L216
vim.api.nvim_win_is_valid() (with possibly quick return) would be run at the beginning win_apply_config independently what part caused it, even if those other broken parts require to be fixed independently.

Noice Log
The part of the log shown below seems to show more than I described above.

Noice log
czw, 10 lis 2022, 19:55:28
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:135: attempt to call field '_fn' (a nil value)

stack traceback:
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:140: in function '_fn'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:135: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:134>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function 'handler'
...tgx/tmp/nvim-from-src/share/nvim/runtime/lua/vim/lsp.lua:1054: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

czw, 10 lis 2022, 19:57:41
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:190: Invalid window id: 1476

stack traceback:
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:140: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:139>
[C]: in function 'nvim_win_set_option'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:190: in function 'set_win_options'
...x/.vim/pack/bundle/opt/noice.nvim/lua/noice/view/nui.lua:274: in function <...x/.vim/pack/bundle/opt/noice.nvim/lua/noice/view/nui.lua:253>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function 'try'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:136: in function 'display'
.../pack/bundle/opt/noice.nvim/lua/noice/message/router.lua:160: in function <.../pack/bundle/opt/noice.nvim/lua/noice/message/router.lua:97>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:130>
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/init.lua:105: in function ''
vim/_editor.lua: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

czw, 10 lis 2022, 19:57:44
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:190: Invalid window id: 1476

stack traceback:
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:140: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:139>
[C]: in function 'nvim_win_set_option'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:190: in function 'set_win_options'
...x/.vim/pack/bundle/opt/noice.nvim/lua/noice/view/nui.lua:274: in function <...x/.vim/pack/bundle/opt/noice.nvim/lua/noice/view/nui.lua:253>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function 'try'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:136: in function 'display'
.../pack/bundle/opt/noice.nvim/lua/noice/message/router.lua:160: in function <.../pack/bundle/opt/noice.nvim/lua/noice/message/router.lua:97>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:130>
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/init.lua:105: in function ''
vim/_editor.lua: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

czw, 10 lis 2022, 19:57:45
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:190: Invalid window id: 1476

stack traceback:
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:140: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:139>
[C]: in function 'nvim_win_set_option'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:190: in function 'set_win_options'
...x/.vim/pack/bundle/opt/noice.nvim/lua/noice/view/nui.lua:274: in function <...x/.vim/pack/bundle/opt/noice.nvim/lua/noice/view/nui.lua:253>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function 'try'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:136: in function 'display'
.../pack/bundle/opt/noice.nvim/lua/noice/message/router.lua:160: in function <.../pack/bundle/opt/noice.nvim/lua/noice/message/router.lua:97>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:130>
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/init.lua:105: in function ''
vim/_editor.lua: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

czw, 10 lis 2022, 20:01:14
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:135: attempt to call field '_fn' (a nil value)

stack traceback:
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:140: in function '_fn'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:135: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:134>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function 'handler'
...tgx/tmp/nvim-from-src/share/nvim/runtime/lua/vim/lsp.lua:1054: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

czw, 10 lis 2022, 20:11:19
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:135: attempt to call field '_fn' (a nil value)

stack traceback:
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:140: in function '_fn'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:135: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:134>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function 'handler'
...tgx/tmp/nvim-from-src/share/nvim/runtime/lua/vim/lsp.lua:1054: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

czw, 10 lis 2022, 20:13:37
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:135: attempt to call field '_fn' (a nil value)

stack traceback:
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:140: in function '_fn'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:135: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:134>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function 'handler'
...tgx/tmp/nvim-from-src/share/nvim/runtime/lua/vim/lsp.lua:1054: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

czw, 10 lis 2022, 20:13:44
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:190: Invalid window id: 1186

stack traceback:
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:140: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:139>
[C]: in function 'nvim_win_set_option'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:190: in function 'set_win_options'
...x/.vim/pack/bundle/opt/noice.nvim/lua/noice/view/nui.lua:274: in function <...x/.vim/pack/bundle/opt/noice.nvim/lua/noice/view/nui.lua:253>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function 'try'
...
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function 'try'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/view/init.lua:136: in function 'display'
.../pack/bundle/opt/noice.nvim/lua/noice/message/router.lua:160: in function <.../pack/bundle/opt/noice.nvim/lua/noice/message/router.lua:97>
[C]: in function 'xpcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:145: in function <.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/call.lua:130>
[C]: in function 'pcall'
.../.vim/pack/bundle/opt/noice.nvim/lua/noice/util/init.lua:105: in function ''
vim/_editor.lua: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

Edit: having the bug in the hands I decided to check one extra part: whether or not the user interface can be used to clear autocommands with the broken state and save the neovim session in easier way. :Noice disable and :Noice enable did a good job! 👍

@przepompownia przepompownia added the bug Something isn't working label Nov 19, 2022
@folke folke closed this as completed in 74c7e29 Nov 20, 2022
@przepompownia
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant