"*class definition*"
"*function definition*"))
+(defun python-imenu--get-defun-type-name ()
+ "Return defun type and name at current position."
+ (when (looking-at python-nav-beginning-of-defun-regexp)
+ (let ((split (split-string (match-string-no-properties 0))))
+ (if (= (length split) 2)
+ split
+ (list (concat (car split) " " (cadr split))
+ (car (last split)))))))
+
(defun python-imenu--put-parent (type name pos tree)
"Add the parent with TYPE, NAME and POS to TREE."
(let ((label
(setq min-indent (or min-indent 0)
prev-indent (or prev-indent python-indent-offset))
(let* ((pos (python-nav-backward-defun))
- (type)
- (name (when (and pos (looking-at python-nav-beginning-of-defun-regexp))
- (let ((split (split-string (match-string-no-properties 0))))
- (setq type (car split))
- (cadr split))))
+ (defun-type-name (and pos (python-imenu--get-defun-type-name)))
+ (type (car defun-type-name))
+ (name (cadr defun-type-name))
(label (when name
(funcall python-imenu-format-item-label-function type name)))
(indent (current-indentation))
def c(self):
pass
+
+ async def d(self):
+ pass
"
(goto-char (point-max))
(should (equal
(list
"Frob (class)"
(cons "*class definition*" (copy-marker 601))
- (cons "c (def)" (copy-marker 626)))))
+ (cons "c (def)" (copy-marker 626))
+ (cons "d (async def)" (copy-marker 665)))))
(python-imenu-create-index)))))
(ert-deftest python-imenu-create-index-2 ()
def c(self):
pass
+
+ async def d(self):
+ pass
"
(goto-char (point-max))
(should (equal
(cons "Baz.a" (copy-marker 539))
(cons "Baz.b" (copy-marker 570))
(cons "Baz.Frob" (copy-marker 601))
- (cons "Baz.Frob.c" (copy-marker 626)))
+ (cons "Baz.Frob.c" (copy-marker 626))
+ (cons "Baz.Frob.d" (copy-marker 665)))
(python-imenu-create-flat-index)))))
(ert-deftest python-imenu-create-flat-index-2 ()