From 40eb32cd81e3ae9836ed3b761a04704aa8d3080b Mon Sep 17 00:00:00 2001 From: Mika Vilpas Date: Fri, 19 Apr 2024 18:41:26 +0300 Subject: [PATCH] fix(window): try to always close the window when focus is lost --- lua/yazi/window.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lua/yazi/window.lua b/lua/yazi/window.lua index f1dcafa6..170abc3e 100644 --- a/lua/yazi/window.lua +++ b/lua/yazi/window.lua @@ -96,10 +96,12 @@ function YaziFloatingWindow:open_and_display() vim.cmd('setlocal winhl=NormalFloat:YaziFloat') vim.cmd('set winblend=' .. self.config.yazi_floating_window_winblend) - -- use autocommand to ensure that the border_buffer closes at the same time as the main buffer - vim.cmd("autocmd WinLeave silent! execute 'hide'") - local cmd = [[autocmd WinLeave silent! execute 'silent bdelete! %s']] - vim.cmd(cmd:format(border_buffer)) + vim.api.nvim_create_autocmd('WinLeave', { + buffer = yazi_buffer, + callback = function() + self:close() + end, + }) self.win = win self.border_window = border_window