nui.nvim icon indicating copy to clipboard operation
nui.nvim copied to clipboard

fix invalid winid in Popup:_open_window

Open konosubakonoakua opened this issue 1 year ago • 8 comments

winid is not nil, not meaning it is valid.

konosubakonoakua avatar May 23 '24 04:05 konosubakonoakua

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

konosubakonoakua avatar May 23 '24 04:05 konosubakonoakua

When I'm using <C-w>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

MunifTanjim avatar May 23 '24 07:05 MunifTanjim

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 avatar May 23 '24 07:05 konosubakonoakua

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

konosubakonoakua avatar May 23 '24 07:05 konosubakonoakua

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.

MunifTanjim avatar May 23 '24 07:05 MunifTanjim

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. 😭

konosubakonoakua avatar May 23 '24 08:05 konosubakonoakua

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

MunifTanjim avatar Jun 05 '24 05:06 MunifTanjim

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.

brunnseb avatar Jun 18 '24 08:06 brunnseb