mirror of
https://github.com/neovim/neovim.git
synced 2026-06-16 08:41:15 +00:00
fix(vim.hl): range(0,…) highlight not cleared after buffer-switch #40130
Problem:
When `vim.hl.range(0, …, { timeout = N })` is called, the deferred
`range_hl_clear` captures `buf=0`, which resolves to an arbitrary
"current buffer" at timeout. This may cause a stale highlight that never
gets cleared.
Solution:
Resolve `buf=0` explicitly, before `range_hl_clear` captures it.
(cherry picked from commit ec7dab077b)
This commit is contained in:
committed by
github-actions[bot]
parent
3a3405d964
commit
be4e7cfd6a
@@ -49,6 +49,8 @@ M.priorities = {
|
||||
--- @return fun()? range_clear A function which allows clearing the highlight manually.
|
||||
--- nil is returned if timeout is not specified
|
||||
function M.range(buf, ns, higroup, start, finish, opts)
|
||||
-- Resolve buf=0 so the deferred `range_hl_clear` works correctly even after buffer-switch.
|
||||
buf = vim._resolve_bufnr(buf)
|
||||
opts = opts or {}
|
||||
local regtype = opts.regtype or 'v'
|
||||
local inclusive = opts.inclusive or false
|
||||
|
||||
Reference in New Issue
Block a user