MunifTanjim / nui.nvim

UI Component Library for Neovim.
MIT License
1.62k stars 57 forks source link

fix invalid winid in Popup:_open_window #367

Open konosubakonoakua opened 4 months ago

konosubakonoakua commented 4 months ago

winid is not nil, not meaning it is valid.

konosubakonoakua commented 4 months ago

should fix #357 When I'm using <C-w>o there is chance to trigger #357.

MunifTanjim commented 4 months ago

When I'm using o there is chance to trigger https://github.com/MunifTanjim/nui.nvim/issues/357

Can you give me an example where this could happen? 🤔

There is a WinClosed callback where self.winid is set to nil when window is closed. https://github.com/MunifTanjim/nui.nvim/blob/a3597dc88b53489d3fddbddbbd13787355253bb0/lua/nui/popup/init.lua#L233-L240

konosubakonoakua commented 4 months ago

When I'm using o there is chance to trigger #357

Can you give me an example where this could happen? 🤔

There is a WinClosed callback where self.winid is set to nil when window is closed.

https://github.com/MunifTanjim/nui.nvim/blob/a3597dc88b53489d3fddbddbbd13787355253bb0/lua/nui/popup/init.lua#L233-L240

It's hard to tell, mostly with neotree open and several horizontal windows, after <C-w>o or <C-w>c there is a chance to happen, not everytime, the only debug info is invalid window error from nui.nvim. 🤕 Maybe the win is close by some other plugins. I'm wondering if we can produce a intentional invalid winid which is not nil.

konosubakonoakua commented 4 months ago

found something in neovim repo, not sure related or not. fix(treesitter): update window if inspected buffer is still open #28922

MunifTanjim commented 4 months ago

found something in neovim repo, not sure related or not. https://github.com/neovim/neovim/pull/28922/

I don't think that's related to nui.nvim at all.

the only debug info is invalid window error from nui.nvim

Can you post that here? or maybe a recording? so that I can understand the issue better.

konosubakonoakua commented 4 months ago

found something in neovim repo, not sure related or not. neovim/neovim#28922

I don't think that's related to nui.nvim at all.

the only debug info is invalid window error from nui.nvim

Can you post that here? or maybe a recording? so that I can understand the issue better.

...x/.local/share/nvim/lazy/nui.nvim/lua/nui/popup/init.lua:168: Invalid window id: 1173

I just triggered this issue with this patch, this pr is not working. 😭

MunifTanjim commented 4 months ago

First step of solving it would be to find out how to reproduce it consistently.

brunnseb commented 4 months ago

I don't really have the time currently to further investigate why it's happening, but here is a way to consistently reproduce the issue using the huynle/ogpt.nvim plugin:

  1. Configure the plugin to use folke/edgy.nvim according to the plugins README (https://github.com/huynle/ogpt.nvim)
  2. Open the chat window by using the OGPT command
  3. Close the chat window (<C-c>)
  4. Try to open the chat window again with command OGPT
  5. Error

If I do Lazy reload ogpt.nvim in between the error does not appear and everything works as expected.