emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 e30621caa2 3/5: ; Add treesit_recursion_limit


From: Yuan Fu
Subject: emacs-29 e30621caa2 3/5: ; Add treesit_recursion_limit
Date: Sat, 24 Dec 2022 03:33:28 -0500 (EST)

branch: emacs-29
commit e30621caa2c93018d137a5b75fb0db897b6db9a8
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    ; 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.
---
 src/treesit.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/treesit.c b/src/treesit.c
index dc2043e610..ce8a280443 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -404,6 +404,10 @@ init_treesit_functions (void)
 
 /*** 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;
 
 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);
   TSNode root = ts_tree_root_node (XTS_PARSER (parser)->tree);
   *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)
     ts_tree_cursor_delete (cursor);
   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
      discussion.  */
-  ptrdiff_t the_limit = 1000;
+  ptrdiff_t the_limit = treesit_recursion_limit;
   if (!NILP (limit))
     {
       CHECK_FIXNUM (limit);
@@ -3150,7 +3155,7 @@ a regexp.  */)
 
   /* We use a default limit of 1000.  See bug#59426 for the
      discussion.  */
-  ptrdiff_t the_limit = 1000;
+  ptrdiff_t the_limit = treesit_recursion_limit;
   if (!NILP (limit))
     {
       CHECK_FIXNUM (limit);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]