From: Randy Taylor <dev@rjt.dev>
Date: Sun, 28 May 2023 00:52:37 +0000 (-0400)
Subject: dockerfile-ts-mode: Prevent empty categories in imenu (Bug#63759)
X-Git-Tag: emacs-29.0.92~71
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ed4cd3eddf7763a70630df8fd238592e6f3b881c;p=emacs.git

dockerfile-ts-mode: Prevent empty categories in imenu (Bug#63759)

* lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode--imenu):
Don't include empty categories.
---

diff --git a/lisp/progmodes/dockerfile-ts-mode.el b/lisp/progmodes/dockerfile-ts-mode.el
index f2f30cf2617..2973b5149db 100644
--- a/lisp/progmodes/dockerfile-ts-mode.el
+++ b/lisp/progmodes/dockerfile-ts-mode.el
@@ -123,8 +123,9 @@ continuation to the previous entry."
   (let* ((node (treesit-buffer-root-node))
          (stage-tree (treesit-induce-sparse-tree
                       node "from_instruction"
-                      nil 1000)))
-    `(("Stage" . ,(dockerfile-ts-mode--imenu-1 stage-tree)))))
+                      nil 1000))
+         (stage-index (dockerfile-ts-mode--imenu-1 stage-tree)))
+    (when stage-index `(("Stage" . ,stage-index)))))
 
 (defun dockerfile-ts-mode--imenu-1 (node)
   "Helper for `dockerfile-ts-mode--imenu'.