Files
neovim/runtime/lua/vim/treesitter
Lewis Russell ea878f456a fix(treesitter): ignore stale fold refresh callbacks
Problem:

The fold refresh path for foldminlines/foldnestmax creates a new
FoldInfo and starts an async parse. If FileType or BufUnload re-enters
before that callback returns, foldinfos[bufnr] can be cleared or
replaced. The callback then indexes a stale slot and raises an "attempt
to index a nil value" error.

Solution:

Capture the FoldInfo created for the refresh and carry that object
through the async callback. Before calling foldupdate(), verify that the
buffer still points at the same FoldInfo generation; otherwise ignore
the stale callback.

AI-assisted: Codex

Fixes #38461
2026-03-25 16:12:52 +00:00
..
2026-03-20 23:30:09 +01:00