static Lisp_Object Vtreesit_str_equal;
static Lisp_Object Vtreesit_str_match;
static Lisp_Object Vtreesit_str_pred;
+static Lisp_Object Vtreesit_str_empty;
/* This is the limit on recursion levels for some tree-sitter
functions. Remember to update docstrings when changing this value.
treesit_initialize ();
TSNode treesit_node = XTS_NODE (node)->node;
+ /* ts_node_type could return NULL, see source code. */
const char *type = ts_node_type (treesit_node);
- return build_string (type);
+ return type == NULL ? Vtreesit_str_empty : build_string (type);
}
DEFUN ("treesit-node-start",
staticpro (&Vtreesit_str_match);
Vtreesit_str_match = build_string ("match");
staticpro (&Vtreesit_str_pred);
- Vtreesit_str_pred = build_string ("pred");
+ Vtreesit_str_pred = build_pure_c_string ("pred");
+ staticpro (&Vtreesit_str_empty);
+ Vtreesit_str_empty = build_pure_c_string ("");
defsubr (&Streesit_language_available_p);
defsubr (&Streesit_library_abi_version);