; Add treesit_recursion_limit
* src/treesit.c (treesit_recursion_limit): New constant. (treesit_cursor_helper) (Ftreesit_search_subtree) (Ftreesit_induce_sparse_tree): Use the new constant.
This commit is contained in:
parent
6a43af5880
commit
e30621caa2
1 changed files with 8 additions and 3 deletions
|
@ -404,6 +404,10 @@ init_treesit_functions (void)
|
||||||
|
|
||||||
/*** Initialization */
|
/*** Initialization */
|
||||||
|
|
||||||
|
/* This is the limit on recursion levels for some tree-sitter
|
||||||
|
functions. Remember to update docstrings when changing this
|
||||||
|
value. */
|
||||||
|
const ptrdiff_t treesit_recursion_limit = 1000;
|
||||||
bool treesit_initialized = false;
|
bool treesit_initialized = false;
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -2706,7 +2710,8 @@ treesit_cursor_helper (TSTreeCursor *cursor, TSNode node, Lisp_Object parser)
|
||||||
uint32_t end_pos = ts_node_end_byte (node);
|
uint32_t end_pos = ts_node_end_byte (node);
|
||||||
TSNode root = ts_tree_root_node (XTS_PARSER (parser)->tree);
|
TSNode root = ts_tree_root_node (XTS_PARSER (parser)->tree);
|
||||||
*cursor = ts_tree_cursor_new (root);
|
*cursor = ts_tree_cursor_new (root);
|
||||||
bool success = treesit_cursor_helper_1 (cursor, &node, end_pos, 1000);
|
bool success = treesit_cursor_helper_1 (cursor, &node, end_pos,
|
||||||
|
treesit_recursion_limit);
|
||||||
if (!success)
|
if (!success)
|
||||||
ts_tree_cursor_delete (cursor);
|
ts_tree_cursor_delete (cursor);
|
||||||
return success;
|
return success;
|
||||||
|
@ -2971,7 +2976,7 @@ Return the first matched node, or nil if none matches. */)
|
||||||
|
|
||||||
/* We use a default limit of 1000. See bug#59426 for the
|
/* We use a default limit of 1000. See bug#59426 for the
|
||||||
discussion. */
|
discussion. */
|
||||||
ptrdiff_t the_limit = 1000;
|
ptrdiff_t the_limit = treesit_recursion_limit;
|
||||||
if (!NILP (limit))
|
if (!NILP (limit))
|
||||||
{
|
{
|
||||||
CHECK_FIXNUM (limit);
|
CHECK_FIXNUM (limit);
|
||||||
|
@ -3150,7 +3155,7 @@ a regexp. */)
|
||||||
|
|
||||||
/* We use a default limit of 1000. See bug#59426 for the
|
/* We use a default limit of 1000. See bug#59426 for the
|
||||||
discussion. */
|
discussion. */
|
||||||
ptrdiff_t the_limit = 1000;
|
ptrdiff_t the_limit = treesit_recursion_limit;
|
||||||
if (!NILP (limit))
|
if (!NILP (limit))
|
||||||
{
|
{
|
||||||
CHECK_FIXNUM (limit);
|
CHECK_FIXNUM (limit);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue