diff options
author | Yuan Fu <casouri@gmail.com> | 2022-11-20 16:56:33 -0800 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2022-11-20 17:04:58 -0800 |
commit | 32870d2f207536bb7932beeb2e0ec9a4e0146560 (patch) | |
tree | 7178d8a11d9b575306118a3fddbcd39e284bb359 /lisp/progmodes/js.el | |
parent | 625ea08652053617034bf8ceee0d6cfae34f2dcc (diff) | |
download | emacs-32870d2f207536bb7932beeb2e0ec9a4e0146560.tar.gz emacs-32870d2f207536bb7932beeb2e0ec9a4e0146560.tar.bz2 emacs-32870d2f207536bb7932beeb2e0ec9a4e0146560.zip |
Limit recursion level for tree-sitter imenu functions
Generating imenu index doesn't require going down to the bottom of the
tree (defun's are usually top-level). Add limit so we don't go too
far down on very large buffers.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--imenu)
* lisp/progmodes/java-ts-mode.el (java-ts-mode--imenu)
* lisp/progmodes/js.el (js--treesit-imenu)
* lisp/progmodes/json-ts-mode.el (json-ts-mode--imenu)
* lisp/progmodes/python.el (python-imenu-treesit-create-index)
* lisp/textmodes/css-mode.el (css--treesit-imenu): Add limit to
treesit-induce-sparse-tree.
Diffstat (limited to 'lisp/progmodes/js.el')
-rw-r--r-- | lisp/progmodes/js.el | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 4b07c0d12c8..50674a1c039 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3688,11 +3688,12 @@ definition*\"." (let* ((node (treesit-buffer-root-node)) (class-tree (treesit-induce-sparse-tree node (rx (or "class_declaration" - "method_definition")))) + "method_definition")) + nil 1000)) (func-tree (treesit-induce-sparse-tree - node "function_declaration")) + node "function_declaration" nil 1000)) (var-tree (treesit-induce-sparse-tree - node "lexical_declaration"))) + node "lexical_declaration" nil 1000))) `(("Class" . ,(js--treesit-imenu-1 class-tree)) ("Varieable" . ,(js--treesit-imenu-1 var-tree)) ("Function" . ,(js--treesit-imenu-1 func-tree))))) |