fix(lib): properly account for aliased root nodes and root nodes with

children in `ts_subtree_string`
This commit is contained in:
Amaan Qureshi 2024-03-18 02:50:01 -04:00
parent ab485da756
commit 24a68697ac
3 changed files with 21 additions and 6 deletions

View file

@ -439,7 +439,14 @@ const char *ts_node_grammar_type(TSNode self) {
}
char *ts_node_string(TSNode self) {
return ts_subtree_string(ts_node__subtree(self), self.tree->language, false);
TSSymbol alias_symbol = ts_node__alias(&self);
return ts_subtree_string(
ts_node__subtree(self),
alias_symbol,
ts_language_symbol_metadata(self.tree->language, alias_symbol).visible,
self.tree->language,
false
);
}
bool ts_node_eq(TSNode self, TSNode other) {