mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-07 06:50:23 -08:00
Handle the case when ts_node_type returns NULL (bug#78938)
* src/treesit.c (Ftreesit_node_type): Handle NULL.
This commit is contained in:
parent
985ad1da76
commit
30dae2ad23
1 changed files with 5 additions and 1 deletions
|
|
@ -426,6 +426,7 @@ static Lisp_Object Vtreesit_str_space;
|
||||||
static Lisp_Object Vtreesit_str_equal;
|
static Lisp_Object Vtreesit_str_equal;
|
||||||
static Lisp_Object Vtreesit_str_match;
|
static Lisp_Object Vtreesit_str_match;
|
||||||
static Lisp_Object Vtreesit_str_pred;
|
static Lisp_Object Vtreesit_str_pred;
|
||||||
|
static Lisp_Object Vtreesit_str_empty;
|
||||||
|
|
||||||
/* This is the limit on recursion levels for some tree-sitter
|
/* This is the limit on recursion levels for some tree-sitter
|
||||||
functions. Remember to update docstrings when changing this value.
|
functions. Remember to update docstrings when changing this value.
|
||||||
|
|
@ -2042,8 +2043,9 @@ If NODE is nil, return nil. */)
|
||||||
treesit_initialize ();
|
treesit_initialize ();
|
||||||
|
|
||||||
TSNode treesit_node = XTS_NODE (node)->node;
|
TSNode treesit_node = XTS_NODE (node)->node;
|
||||||
|
/* ts_node_type could return NULL, see source code. */
|
||||||
const char *type = ts_node_type (treesit_node);
|
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",
|
DEFUN ("treesit-node-start",
|
||||||
|
|
@ -4334,6 +4336,8 @@ the symbol of that THING. For example, (or sexp sentence). */);
|
||||||
Vtreesit_str_match = build_pure_c_string ("match");
|
Vtreesit_str_match = build_pure_c_string ("match");
|
||||||
staticpro (&Vtreesit_str_pred);
|
staticpro (&Vtreesit_str_pred);
|
||||||
Vtreesit_str_pred = build_pure_c_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_language_available_p);
|
||||||
defsubr (&Streesit_library_abi_version);
|
defsubr (&Streesit_library_abi_version);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue