From ddbc09bb984f0ca0796de2ac7cb27cfb57a0c6da Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 2 Oct 2024 14:12:45 +0100 Subject: [PATCH] fix: add desc node for child_containing_descendant --- lua/treesitter-context/context.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/treesitter-context/context.lua b/lua/treesitter-context/context.lua index df13a66e..b40233b1 100644 --- a/lua/treesitter-context/context.lua +++ b/lua/treesitter-context/context.lua @@ -27,11 +27,12 @@ local function get_parent_nodes(langtree, range) local ret = {} --- @type TSNode[] if root.child_containing_descendant ~= nil then - local p = root + local p = root --- @type TSNode? while p do table.insert(ret, 1, p) p = p:child_containing_descendant(n) end + table.insert(ret, 1, n) else while n do ret[#ret + 1] = n