Skip to content

Commit

Permalink
fix(window): handle when a PersistedWindow's buffer has been deleted (#…
Browse files Browse the repository at this point in the history
…434)

Adds an additional check to the self.buffer function of PersistedWindow
to see if the current bufnr still exists. This prevents a crash in cases
where the persisted window's buffer has been deleted by an external
script.

Fixes N/A

Co-authored-by: Cody Mikol <hi@codymikol.com>
  • Loading branch information
codymikol and Cody Mikol authored Jul 11, 2024
1 parent 26ed905 commit 46adcd0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/neotest/lib/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ function PersistentWindow:open()
end

function PersistentWindow:buffer()
if self._bufnr then
if self._bufnr and vim.fn.bufexists(self._bufnr) == 1 then
return self._bufnr
end

self._bufnr = nio.api.nvim_create_buf(false, true)
nio.api.nvim_buf_set_name(self._bufnr, self.name)
for k, v in pairs(self._bufopts) do
Expand Down

0 comments on commit 46adcd0

Please sign in to comment.