mirror of
https://github.com/neovim/neovim.git
synced 2026-04-21 23:05:41 +00:00
fix(treesitter): ensure TSLuaTree is always immutable
Problem:
The previous fix in #34314 relies on copying the tree in `tree_root` to
ensure the `TSNode`'s tree cannot be mutated. But that causes the
problem where two calls to `tree_root` return nodes from different
copies of a tree, which do not compare as equal. This has broken at
least one plugin.
Solution:
Make all `TSTree`s on the Lua side always immutable, avoiding the need
to copy the tree in `tree_root`, and make the only mutation point,
`tree_edit`, copy the tree instead.
(cherry picked from commit 168bf0024e)
This commit is contained in:
committed by
github-actions[bot]
parent
37fb09c162
commit
a80bdf0d9b
@@ -26,6 +26,7 @@ function TSTree:root() end
|
||||
---@param end_col_old integer
|
||||
---@param end_row_new integer
|
||||
---@param end_col_new integer
|
||||
---@return TSTree
|
||||
---@nodoc
|
||||
function TSTree:edit(start_byte, end_byte_old, end_byte_new, start_row, start_col, end_row_old, end_col_old, end_row_new, end_col_new) end
|
||||
|
||||
|
||||
@@ -1082,8 +1082,8 @@ function LanguageTree:_edit(
|
||||
end_row_new,
|
||||
end_col_new
|
||||
)
|
||||
for _, tree in pairs(self._trees) do
|
||||
tree:edit(
|
||||
for i, tree in pairs(self._trees) do
|
||||
self._trees[i] = tree:edit(
|
||||
start_byte,
|
||||
end_byte_old,
|
||||
end_byte_new,
|
||||
|
||||
Reference in New Issue
Block a user