fix(files): remove invalid window from explorer.windows#2438
Conversation
explorer.windows
0816617 to
c69f96e
Compare
| H.opened_buffers[buf_id].win_id = nil | ||
| else | ||
| H.window_close() | ||
| explorer.windows[i] = nil |
There was a problem hiding this comment.
In theory, this is not the cleanest assignment as it can introduce "holes" in the array (i.e. explorer.windows[2] = nil while explorer.windows[3] is not nil).
My first instinct tells me that the culprit is probably somewhere else.
There was a problem hiding this comment.
My first instinct tells me that the culprit is probably somewhere else.
Interesting.
When I comment this line, the error does not happen.
There was a problem hiding this comment.
This behavior could potentially happen starting from this commit.
I think it wasn't noticed because the examples don't use get_explorer_state in MiniFilesWindowUpdate. I found it when playing with the code example from the custom side scrolling discussion
There was a problem hiding this comment.
In theory, this is not the cleanest assignment as it can introduce "holes" in the array (i.e. explorer.windows[2] = nil while explorer.windows[3] is not nil).
I fixed that.
|
Thanks for the PR! I can reproduce. And not only after |
c69f96e to
5118a3a
Compare
Details: - When MiniFilesWindowUpdate uses `get_explorer_state()` with enabled preview, an error occurs after the user presses `o`, `<Esc>`, `u`.
5118a3a to
94576dd
Compare
|
After a more research, it looks like the culprit is that the events are triggered too early during the "explorer refresh" cycle. This makes code a bit cleaner, but has a downside of making As usually triggering events when everything is up to date (be it "already up to date" for Thanks again for finding this and making a PR! |
Details:
get_explorer_state()with enabled preview, an error occurs after the user presseso,<Esc>,u.The error:
Error in User Autocommands for "MiniFilesWindowUpdate": Lua callback: ...m-repro/site/pack/vnr/start/mini.nvim/lua/mini/files.lua:1105: Invalid window id: 1004 stack traceback: [C]: in function 'nvim_win_get_buf' ...m-repro/site/pack/vnr/start/mini.nvim/lua/mini/files.lua:1105: in function 'get_explorer_state' /home/user/.config/nvim-repro/init.lua:12: in function </home/user/.config/nvim-repro/init.lua:12> [C]: in function 'nvim_exec_autocmds' ...m-repro/site/pack/vnr/start/mini.nvim/lua/mini/files.lua:3096: in function 'trigger_event' ...m-repro/site/pack/vnr/start/mini.nvim/lua/mini/files.lua:1873: in function 'explorer_refresh_depth_window' ...m-repro/site/pack/vnr/start/mini.nvim/lua/mini/files.lua:1566: in function 'explorer_refresh' ...m-repro/site/pack/vnr/start/mini.nvim/lua/mini/files.lua:2147: in function 'fn' [string "vim/_core/editor"]:408: in function <[string "vim/_core/editor"]:407>Repro:
:lua MiniFiles.open()oand press<Esc>.uThis happens because the preview buffer is deleted. However,
the win_idis still present inexplorer.windows.