fix potential execution bug when nvim_win_close raises exception

This commit is contained in:
bhagwan 2022-03-21 21:39:17 -07:00
parent 6d65097d45
commit c815531334

View File

@ -793,7 +793,10 @@ function FzfWin:close()
self.closing = true self.closing = true
self:close_preview() self:close_preview()
if self.fzf_winid and vim.api.nvim_win_is_valid(self.fzf_winid) then if self.fzf_winid and vim.api.nvim_win_is_valid(self.fzf_winid) then
vim.api.nvim_win_close(self.fzf_winid, {force=true}) -- run in a pcall due to potential errors while closing the window
-- Vim(lua):E5108: Error executing lua
-- experienced while accessing 'vim.b[]' from my statusline code
pcall(vim.api.nvim_win_close, self.fzf_winid, {force=true})
end end
if self.fzf_bufnr and vim.api.nvim_buf_is_valid(self.fzf_bufnr) then if self.fzf_bufnr and vim.api.nvim_buf_is_valid(self.fzf_bufnr) then
vim.api.nvim_buf_delete(self.fzf_bufnr, {force=true}) vim.api.nvim_buf_delete(self.fzf_bufnr, {force=true})