From ab485da75609ec15c7ac6f5bddf43ed948bee9e1 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 18 Mar 2024 02:49:26 -0400 Subject: [PATCH] fix(lib): do not consider childless nodes for `ts_node_parent` --- lib/src/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/node.c b/lib/src/node.c index 546b9099..bb76fcb8 100644 --- a/lib/src/node.c +++ b/lib/src/node.c @@ -513,7 +513,7 @@ TSNode ts_node_parent(TSNode self) { ts_node_start_byte(child) > ts_node_start_byte(self) || child.id == self.id ) break; - if (iterator.position.bytes >= end_byte) { + if (iterator.position.bytes >= end_byte && ts_node_child_count(child) > 0) { node = child; if (ts_node__is_relevant(child, true)) { last_visible_node = node;