Skip to content

Commit

Permalink
fix(window): try to always close the window when focus is lost
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas committed Apr 19, 2024
1 parent a0627cb commit 40eb32c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lua/yazi/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 <buffer> silent! execute 'hide'")
local cmd = [[autocmd WinLeave <buffer> 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
Expand Down

0 comments on commit 40eb32c

Please sign in to comment.