ITADN

yazi.nvim closes unexpectedly when vim.ui.select triggers WinLeave during LSP rename (e.g., with snacks.picker)

#1676Closedhyawara 创建于 2026-03-07
H
hyawaracommented
When renaming a file inside Yazi, yazi.nvim detects the change and prompts the user to apply LSP workspace edits across the project. This prompt uses vim.ui.select. If a user has a UI plugin (like snacks.picker or telescope-ui-select) that overrides vim.ui.select with a floating window, the focus is temporarily stolen from the Yazi terminal window. This immediately triggers the hardcoded WinLeave autocmd in lua/yazi/window.lua, which indiscriminately executes self:close(). As a result, the Yazi process is killed prematurely, and Neovim throws the error: yazi.nvim: had trouble opening yazi. Run ':checkhealth yazi' for more information. Steps to reproduce: Install yazi.nvim and a UI plugin that overrides vim.ui.select with a floating window (e.g., snacks.nvim with picker.ui_select = true). Open yazi in Neovim. Select a file and rename it. yazi.nvim asks for LSP rename confirmation via vim.ui.select. The UI plugin opens a floating window to handle the selection. The Yazi window loses focus, triggers WinLeave, and the plugin forcefully closes the Yazi process. (Note: Even when falling back to the native Neovim vim.ui.select, certain terminal configurations or plugins can still cause a brief focus shift, triggering the same fatal WinLeave event.) Root Cause Analysis: In lua/yazi/window.lua, the WinLeave autocmd is bound directly to the yazi_buffer without any conditional checks: ```lua vim.api.nvim_create_autocmd({ "WinLeave" }, { buffer = yazi_buffer, callback = function() self:close() end, }) ``` This means any action that causes the window to lose focus—even actions initiated by yazi.nvim itself (like an LSP rename prompt)—will kill the file manager. Proposed Solution: It would be greatly appreciated if there was a way to temporarily ignore the WinLeave event when yazi.nvim is invoking internal prompts like vim.ui.select. For instance: Wrap the vim.ui.select call in the LSP rename logic with a state flag (e.g., ignore_winleave = true), and check this flag inside the WinLeave callback before executing self:close(). Or, provide a configuration option to customize or disable the WinLeave auto-close behavior for users who prefer persistent floating windows or use heavy UI plugins.
关闭于 2026-03-13 3 条评论