fix: guard against invalid buffer (#90)

This commit is contained in:
Steven Arcangeli 2023-04-27 07:30:48 -07:00
parent 73d8587ac5
commit a9556aa872

View file

@ -667,6 +667,10 @@ local function load_oil_buffer(bufnr)
loading.set_loading(bufnr, true)
local winid = vim.api.nvim_get_current_win()
local function finish(new_url)
-- If the buffer was deleted while we were normalizing the name, early return
if not vim.api.nvim_buf_is_valid(bufnr) then
return
end
-- Since this was async, we may have left the window with this buffer. People often write
-- BufReadPre/Post autocmds with the expectation that the current window is the one that
-- contains the buffer. Let's then do our best to make sure that that assumption isn't violated.