Skip to content

Commit

Permalink
Autoclose popup window on leave
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed May 27, 2024
1 parent 83af5a1 commit 5ce61c1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lua/fzy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ function M.execute(choices_cmd, on_choice, prompt)
end
local tmpfile = vfn.tempname()
local popup_win, buf = M.new_popup()
api.nvim_create_autocmd("WinLeave", {
callback = function()
local w = vim.api.nvim_get_current_win()
if w == popup_win then
api.nvim_buf_delete(buf, { force = true })
return true
end
end,
})
local height = api.nvim_win_get_height(popup_win)
prompt = prompt and vim.fn.shellescape(prompt) or nil
local cmd = M.command({ height = height, prompt = prompt })
Expand Down

0 comments on commit 5ce61c1

Please # to comment.