neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 28e819018520a2300eaeeec6794ffcd614b25dd2
parent f9dec1228d1741859a89b64de7ac9765f12c2d3d
Author: phanium <91544758+phanen@users.noreply.github.com>
Date:   Sun,  6 Apr 2025 06:56:40 +0800

fix(vim.hl): nvim_buf_del_extmark on invalid buffer #33331

Problem:
nvim_buf_del_extmark error if buffer is destroyed before timer stops

Solution:
check nvim_buf_is_valid.
Diffstat:
Mruntime/lua/vim/hl.lua | 3+++
Mtest/functional/lua/hl_spec.lua | 1+
2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/runtime/lua/vim/hl.lua b/runtime/lua/vim/hl.lua @@ -128,6 +128,9 @@ function M.range(bufnr, ns, higroup, start, finish, opts) end local range_hl_clear = function() + if not api.nvim_buf_is_valid(bufnr) then + return + end for _, mark in ipairs(extmarks) do api.nvim_buf_del_extmark(bufnr, ns, mark) end diff --git a/test/functional/lua/hl_spec.lua b/test/functional/lua/hl_spec.lua @@ -222,6 +222,7 @@ describe('vim.hl.on_yank', function() it('does not show errors even if buffer is wiped before timeout', function() command('new') + n.feed('ifoo<esc>') -- set '[, '] exec_lua(function() vim.hl.on_yank({ timeout = 10,