diff options
author | notomo <notomo.motono@gmail.com> | 2021-08-26 23:37:36 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 16:37:36 +0200 |
commit | 274a3504a790a799b28ee89c75e29fb4dbdff41f (patch) | |
tree | caae17c39de08393d111a97a1c17f534032d17da /runtime/lua/vim/highlight.lua | |
parent | 6ff1e3fa1f6c88e8a8ce4e2e5a017bea8b5e381e (diff) | |
download | rneovim-274a3504a790a799b28ee89c75e29fb4dbdff41f.tar.gz rneovim-274a3504a790a799b28ee89c75e29fb4dbdff41f.tar.bz2 rneovim-274a3504a790a799b28ee89c75e29fb4dbdff41f.zip |
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.
Diffstat (limited to 'runtime/lua/vim/highlight.lua')
-rw-r--r-- | runtime/lua/vim/highlight.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/highlight.lua index 4cb1994419..236f3165f2 100644 --- a/runtime/lua/vim/highlight.lua +++ b/runtime/lua/vim/highlight.lua @@ -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 |