mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
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.
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user