mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
fix(treesitter): remove redundant on_bytes callback #31041
Problem: Treesitter highlighter implements an on_bytes callback that just re-marks a buffer range for redraw. The edit that prompted the callback will already have done that. Solution: Remove redundant on_bytes callback from the treesitter highlighter module.
This commit is contained in:
@@ -1605,8 +1605,7 @@ LanguageTree:register_cbs({cbs}, {recursive})
|
|||||||
• {cbs} (`table<TSCallbackNameOn,function>`) An
|
• {cbs} (`table<TSCallbackNameOn,function>`) An
|
||||||
|nvim_buf_attach()|-like table argument with the
|
|nvim_buf_attach()|-like table argument with the
|
||||||
following handlers:
|
following handlers:
|
||||||
• `on_bytes` : see |nvim_buf_attach()|, but this will be
|
• `on_bytes` : see |nvim_buf_attach()|.
|
||||||
called after the parsers callback.
|
|
||||||
• `on_changedtree` : a callback that will be called every
|
• `on_changedtree` : a callback that will be called every
|
||||||
time the tree has syntactical changes. It will be
|
time the tree has syntactical changes. It will be
|
||||||
passed two arguments: a table of the ranges (as node
|
passed two arguments: a table of the ranges (as node
|
||||||
|
@@ -93,9 +93,6 @@ function TSHighlighter.new(tree, opts)
|
|||||||
opts = opts or {} ---@type { queries: table<string,string> }
|
opts = opts or {} ---@type { queries: table<string,string> }
|
||||||
self.tree = tree
|
self.tree = tree
|
||||||
tree:register_cbs({
|
tree:register_cbs({
|
||||||
on_bytes = function(...)
|
|
||||||
self:on_bytes(...)
|
|
||||||
end,
|
|
||||||
on_detach = function()
|
on_detach = function()
|
||||||
self:on_detach()
|
self:on_detach()
|
||||||
end,
|
end,
|
||||||
@@ -214,13 +211,6 @@ function TSHighlighter:for_each_highlight_state(fn)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@package
|
|
||||||
---@param start_row integer
|
|
||||||
---@param new_end integer
|
|
||||||
function TSHighlighter:on_bytes(_, _, start_row, _, _, _, _, _, new_end)
|
|
||||||
api.nvim__redraw({ buf = self.bufnr, range = { start_row, start_row + new_end + 1 } })
|
|
||||||
end
|
|
||||||
|
|
||||||
---@package
|
---@package
|
||||||
function TSHighlighter:on_detach()
|
function TSHighlighter:on_detach()
|
||||||
self:destroy()
|
self:destroy()
|
||||||
|
@@ -1037,7 +1037,7 @@ end
|
|||||||
|
|
||||||
--- Registers callbacks for the [LanguageTree].
|
--- Registers callbacks for the [LanguageTree].
|
||||||
---@param cbs table<TSCallbackNameOn,function> An [nvim_buf_attach()]-like table argument with the following handlers:
|
---@param cbs table<TSCallbackNameOn,function> An [nvim_buf_attach()]-like table argument with the following handlers:
|
||||||
--- - `on_bytes` : see [nvim_buf_attach()], but this will be called _after_ the parsers callback.
|
--- - `on_bytes` : see [nvim_buf_attach()].
|
||||||
--- - `on_changedtree` : a callback that will be called every time the tree has syntactical changes.
|
--- - `on_changedtree` : a callback that will be called every time the tree has syntactical changes.
|
||||||
--- It will be passed two arguments: a table of the ranges (as node ranges) that
|
--- It will be passed two arguments: a table of the ranges (as node ranges) that
|
||||||
--- changed and the changed tree.
|
--- changed and the changed tree.
|
||||||
|
Reference in New Issue
Block a user