diff options
| author | Yuan Fu | 2022-12-23 17:17:25 -0800 |
|---|---|---|
| committer | Yuan Fu | 2022-12-24 00:33:17 -0800 |
| commit | e30621caa2c93018d137a5b75fb0db897b6db9a8 (patch) | |
| tree | 9eb0c07efb5a572b8973cfbd41e8c0235da9e255 /src | |
| parent | 6a43af58802d46555d692d0934d85d22711e0b56 (diff) | |
| download | emacs-e30621caa2c93018d137a5b75fb0db897b6db9a8.tar.gz emacs-e30621caa2c93018d137a5b75fb0db897b6db9a8.zip | |
; 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/treesit.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/treesit.c b/src/treesit.c index dc2043e6109..ce8a2804439 100644 --- a/src/treesit.c +++ b/src/treesit.c | |||
| @@ -404,6 +404,10 @@ init_treesit_functions (void) | |||
| 404 | 404 | ||
| 405 | /*** Initialization */ | 405 | /*** Initialization */ |
| 406 | 406 | ||
| 407 | /* This is the limit on recursion levels for some tree-sitter | ||
| 408 | functions. Remember to update docstrings when changing this | ||
| 409 | value. */ | ||
| 410 | const ptrdiff_t treesit_recursion_limit = 1000; | ||
| 407 | bool treesit_initialized = false; | 411 | bool treesit_initialized = false; |
| 408 | 412 | ||
| 409 | static bool | 413 | static bool |
| @@ -2706,7 +2710,8 @@ treesit_cursor_helper (TSTreeCursor *cursor, TSNode node, Lisp_Object parser) | |||
| 2706 | uint32_t end_pos = ts_node_end_byte (node); | 2710 | uint32_t end_pos = ts_node_end_byte (node); |
| 2707 | TSNode root = ts_tree_root_node (XTS_PARSER (parser)->tree); | 2711 | TSNode root = ts_tree_root_node (XTS_PARSER (parser)->tree); |
| 2708 | *cursor = ts_tree_cursor_new (root); | 2712 | *cursor = ts_tree_cursor_new (root); |
| 2709 | bool success = treesit_cursor_helper_1 (cursor, &node, end_pos, 1000); | 2713 | bool success = treesit_cursor_helper_1 (cursor, &node, end_pos, |
| 2714 | treesit_recursion_limit); | ||
| 2710 | if (!success) | 2715 | if (!success) |
| 2711 | ts_tree_cursor_delete (cursor); | 2716 | ts_tree_cursor_delete (cursor); |
| 2712 | return success; | 2717 | return success; |
| @@ -2971,7 +2976,7 @@ Return the first matched node, or nil if none matches. */) | |||
| 2971 | 2976 | ||
| 2972 | /* We use a default limit of 1000. See bug#59426 for the | 2977 | /* We use a default limit of 1000. See bug#59426 for the |
| 2973 | discussion. */ | 2978 | discussion. */ |
| 2974 | ptrdiff_t the_limit = 1000; | 2979 | ptrdiff_t the_limit = treesit_recursion_limit; |
| 2975 | if (!NILP (limit)) | 2980 | if (!NILP (limit)) |
| 2976 | { | 2981 | { |
| 2977 | CHECK_FIXNUM (limit); | 2982 | CHECK_FIXNUM (limit); |
| @@ -3150,7 +3155,7 @@ a regexp. */) | |||
| 3150 | 3155 | ||
| 3151 | /* We use a default limit of 1000. See bug#59426 for the | 3156 | /* We use a default limit of 1000. See bug#59426 for the |
| 3152 | discussion. */ | 3157 | discussion. */ |
| 3153 | ptrdiff_t the_limit = 1000; | 3158 | ptrdiff_t the_limit = treesit_recursion_limit; |
| 3154 | if (!NILP (limit)) | 3159 | if (!NILP (limit)) |
| 3155 | { | 3160 | { |
| 3156 | CHECK_FIXNUM (limit); | 3161 | CHECK_FIXNUM (limit); |