From 1f0480d4cdea9a266d73f184c56dc94915f1c67a Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Fri, 12 Jul 2013 22:55:58 -0300 Subject: * lisp/progmodes/python.el (python-imenu--build-tree): Fix corner case in nested defuns. * test/automated/python-tests.el (python-imenu-create-index-2) (python-imenu-create-index-3): New tests. --- lisp/progmodes/python.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 915b52ce04d..62870f9085b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3091,7 +3091,12 @@ you are doing." ;; Stop collecting nodes after moving to a position with ;; indentation equaling min-indent. This is specially ;; useful for navigating nested definitions recursively. - tree) + (if (> num-children 0) + tree + ;; When there are no children, the collected tree is a + ;; single node intended to be added in the list of defuns + ;; of its parent. + (car tree))) (t (python-imenu--build-tree min-indent @@ -3131,7 +3136,7 @@ you are doing." (cons (prog1 (python-imenu--build-tree - prev-indent indent 1 (list (cons label pos))) + prev-indent indent 0 (list (cons label pos))) ;; Adjustment: after scanning backwards ;; for all deeper children, we need to ;; continue our scan for a parent from -- cgit v1.2.1