mirror of
https://github.com/neovim/neovim.git
synced 2026-03-28 11:22:03 +00:00
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