From c0fe6c72cec477fdd2494bf3d26ab75790d2f720 Mon Sep 17 00:00:00 2001 From: Randy Taylor Date: Sun, 11 Dec 2022 20:50:54 -0500 Subject: [PATCH] Improve dockerfile-ts-mode imenu generation (Bug#59979) * lisp/progmodes/dockerfile-ts-mode.el (treesit-node-child-by-field-name): Declare. (dockerfile-ts-mode--imenu-1): Use stage name if available. --- lisp/progmodes/dockerfile-ts-mode.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/dockerfile-ts-mode.el b/lisp/progmodes/dockerfile-ts-mode.el index 544e0f82d6d..40d90cc2dfc 100644 --- a/lisp/progmodes/dockerfile-ts-mode.el +++ b/lisp/progmodes/dockerfile-ts-mode.el @@ -33,6 +33,7 @@ (declare-function treesit-parser-create "treesit.c") (declare-function treesit-induce-sparse-tree "treesit.c") (declare-function treesit-node-child "treesit.c") +(declare-function treesit-node-child-by-field-name "treesit.c") (declare-function treesit-node-start "treesit.c") (declare-function treesit-node-type "treesit.c") @@ -117,8 +118,10 @@ the subtrees." children)) (name (when ts-node (pcase (treesit-node-type ts-node) - ("from_instruction" (treesit-node-text - (treesit-node-child ts-node 1) t))))) + ("from_instruction" + (treesit-node-text + (or (treesit-node-child-by-field-name ts-node "as") + (treesit-node-child ts-node 1)) t))))) (marker (when ts-node (set-marker (make-marker) (treesit-node-start ts-node))))) -- 2.39.2