mirror of
https://github.com/neovim/neovim.git
synced 2026-05-04 21:15:09 +00:00
treesitter: propagate on_detach event properly
This commit is contained in:
@@ -113,8 +113,9 @@ function TSHighlighter.new(tree, opts)
|
||||
opts = opts or {}
|
||||
self.tree = tree
|
||||
tree:register_cbs {
|
||||
on_changedtree = function(...) self:on_changedtree(...) end,
|
||||
on_bytes = function(...) self:on_bytes(...) end
|
||||
on_changedtree = function(...) self:on_changedtree(...) end;
|
||||
on_bytes = function(...) self:on_bytes(...) end;
|
||||
on_detach = function(...) self:on_detach(...) end;
|
||||
}
|
||||
|
||||
self.bufnr = tree:source()
|
||||
@@ -176,6 +177,10 @@ function TSHighlighter:on_bytes(_, _, start_row, _, _, _, _, _, new_end)
|
||||
a.nvim__buf_redraw_range(self.bufnr, start_row, start_row + new_end + 1)
|
||||
end
|
||||
|
||||
function TSHighlighter:on_detach()
|
||||
self:destroy()
|
||||
end
|
||||
|
||||
function TSHighlighter:on_changedtree(changes)
|
||||
for _, ch in ipairs(changes or {}) do
|
||||
a.nvim__buf_redraw_range(self.bufnr, ch[1], ch[3]+1)
|
||||
|
||||
Reference in New Issue
Block a user