mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
Merge pull request #240 from tomtomjhj/buf-invalid
fix: check validity of buffer in deferred callbacks
This commit is contained in:
commit
3d8360f010
4 changed files with 10 additions and 1 deletions
|
@ -190,6 +190,9 @@ M.set_symbols = function(bufnr, items, ctx)
|
|||
-- We need that autocmd to complete first so that it reallocates the existing aerial windows,
|
||||
-- thus the defer. It's a bit of a hack :/
|
||||
vim.defer_fn(function()
|
||||
if not vim.api.nvim_buf_is_valid(bufnr) then
|
||||
return
|
||||
end
|
||||
window.maybe_open_automatic(bufnr)
|
||||
end, 15)
|
||||
end
|
||||
|
|
|
@ -177,6 +177,9 @@ M.symbol_callback = function(_err, result, context, _config)
|
|||
vim.defer_fn(function()
|
||||
local r = results[bufnr]
|
||||
results[bufnr] = nil
|
||||
if not vim.api.nvim_buf_is_valid(bufnr) then
|
||||
return
|
||||
end
|
||||
M.handle_symbols(r, bufnr, client.name)
|
||||
end, 100)
|
||||
end
|
||||
|
|
|
@ -175,7 +175,7 @@ M.flash_highlight = function(bufnr, lnum, durationMs, hl_group)
|
|||
end
|
||||
local ns = vim.api.nvim_buf_add_highlight(bufnr, 0, hl_group, lnum - 1, 0, -1)
|
||||
local remove_highlight = function()
|
||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
||||
pcall(vim.api.nvim_buf_clear_namespace, bufnr, ns, 0, -1)
|
||||
end
|
||||
vim.defer_fn(remove_highlight, durationMs)
|
||||
end
|
||||
|
|
|
@ -48,6 +48,9 @@ local function create_aerial_buffer(bufnr)
|
|||
callback = function(params)
|
||||
-- Defer it so we have time to set window options and variables on the float first
|
||||
vim.defer_fn(function()
|
||||
if not vim.api.nvim_buf_is_valid(bufnr) then
|
||||
return
|
||||
end
|
||||
render.update_aerial_buffer(aer_bufnr)
|
||||
M.update_all_positions(bufnr, 0)
|
||||
M.center_symbol_in_view(bufnr)
|
||||
|
|
Loading…
Reference in a new issue