summaryrefslogtreecommitdiff
path: root/lisp/progmodes/js.el
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2022-12-21 06:30:10 +0100
committerStefan Kangas <stefankangas@gmail.com>2022-12-21 06:30:10 +0100
commit05740f05b732a5df473bdf9d1750e97f6a86f2c0 (patch)
treefd9d1737251ecff28911cc111285960fa01ced8c /lisp/progmodes/js.el
parente871f21348a737541b181445c911dd58c34e9a47 (diff)
parent12b2b8864c295ce27594e8a907ebb3423e58a9d4 (diff)
downloademacs-05740f05b732a5df473bdf9d1750e97f6a86f2c0.tar.gz
Merge from origin/emacs-29
12b2b8864c2 Fix empty pairs in js tree-sitter imenu alist (bug#59945) 6d9f367ead3 ; * lisp/treesit.el (treesit-simple-indent-presets): Fix ...
Diffstat (limited to 'lisp/progmodes/js.el')
-rw-r--r--lisp/progmodes/js.el11
1 files changed, 8 insertions, 3 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index cbcca81baaa..15272dcc002 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3738,9 +3738,14 @@ definition*\"."
node "function_declaration" nil 1000))
(var-tree (treesit-induce-sparse-tree
node "lexical_declaration" nil 1000)))
- `(("Class" . ,(js--treesit-imenu-1 class-tree))
- ("Variable" . ,(js--treesit-imenu-1 var-tree))
- ("Function" . ,(js--treesit-imenu-1 func-tree)))))
+ ;; When a sub-tree is empty, we should not return that pair at all.
+ (append
+ (and func-tree
+ `(("Function" . ,(js--treesit-imenu-1 func-tree))))
+ (and var-tree
+ `(("Variable" . ,(js--treesit-imenu-1 var-tree))))
+ (and class-tree
+ `(("Class" . ,(js--treesit-imenu-1 class-tree)))))))
;;; Main Function