mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
fix(lua): verify buffer in highlight.on_yank (#15482)
Resolve an issue with deferred clearing of highlight failing if the buffer is deleted before the timeout by checking whether the buffer is valid first.
This commit is contained in:
@@ -85,7 +85,11 @@ function highlight.on_yank(opts)
|
||||
highlight.range(bufnr, yank_ns, higroup, pos1, pos2, event.regtype, event.inclusive)
|
||||
|
||||
vim.defer_fn(
|
||||
function() api.nvim_buf_clear_namespace(bufnr, yank_ns, 0, -1) end,
|
||||
function()
|
||||
if api.nvim_buf_is_valid(bufnr) then
|
||||
api.nvim_buf_clear_namespace(bufnr, yank_ns, 0, -1)
|
||||
end
|
||||
end,
|
||||
timeout
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user