neovim

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

commit e7ebc5c13d2d1658005a7fb477bc92718044746f
parent 19f00bf32cebfa66a17e0f5945d62d7da1859623
Author: notomo <notomo.motono@gmail.com>
Date:   Sat, 25 Jan 2025 21:15:01 +0900

fix(treesitter): stop async parsing if buffer is invalid

Problem: Error occurs if delete buffer in the middle of parsing.
Solution: Check if buffer is valid in parsing.

Diffstat:
Mruntime/lua/vim/treesitter/languagetree.lua | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua @@ -475,13 +475,18 @@ function LanguageTree:_async_parse(range, on_parse) return end - local buf = vim.b[self._source] + local source = self._source + local buf = vim.b[source] local ct = buf.changedtick local total_parse_time = 0 local redrawtime = vim.o.redrawtime local timeout = not vim.g._ts_force_sync_parsing and default_parse_timeout_ms or nil local function step() + if type(source) == 'number' and not vim.api.nvim_buf_is_valid(source) then + return nil + end + -- If buffer was changed in the middle of parsing, reset parse state if buf.changedtick ~= ct then ct = buf.changedtick