aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter.lua
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/treesitter.lua')
-rw-r--r--runtime/lua/vim/treesitter.lua12
1 files changed, 2 insertions, 10 deletions
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index 809ea59b94..baf47482a8 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -159,16 +159,8 @@ function M.is_ancestor(dest, source)
return false
end
- local current = source ---@type TSNode?
- while current ~= nil do
- if current == dest then
- return true
- end
-
- current = current:parent()
- end
-
- return false
+ -- child_containing_descendant returns nil if dest is a direct parent
+ return source:parent() == dest or dest:child_containing_descendant(source) ~= nil
end
--- Returns the node's range or an unpacked range table