diff options
author | kobarity <kobarity@gmail.com> | 2022-07-16 18:14:15 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-07-16 18:26:58 +0200 |
commit | 35d0a2e0a767838c24d5853be798313aed7a42df (patch) | |
tree | d753ec8cb392e55964f41e2180f45608fe3dc106 /test/lisp/progmodes | |
parent | 9b5eb661bf01d5b7e3453011b93f0eaf8621521e (diff) | |
download | emacs-35d0a2e0a767838c24d5853be798313aed7a42df.tar.gz emacs-35d0a2e0a767838c24d5853be798313aed7a42df.tar.bz2 emacs-35d0a2e0a767838c24d5853be798313aed7a42df.zip |
Fix python navigation problem with an empty line in nested defun
* lisp/progmodes/python.el (python-nav--beginning-of-defun): Fix
bug when point is on an empty line (bug#56600).
Diffstat (limited to 'test/lisp/progmodes')
-rw-r--r-- | test/lisp/progmodes/python-tests.el | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 92c20288c8e..b2cccdd9569 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -1876,7 +1876,7 @@ class C(object): (beginning-of-line) (point)))) ;; Nested defuns should be skipped. - (python-tests-look-at "return a" -1) + (forward-line -1) (should (= (save-excursion (python-nav-beginning-of-defun) (point)) @@ -1885,6 +1885,15 @@ class C(object): (beginning-of-line) (point)))) ;; Defuns on same levels should be respected. + (python-tests-look-at "if True:" -1) + (forward-line -1) + (should (= (save-excursion + (python-nav-beginning-of-defun) + (point)) + (save-excursion + (python-tests-look-at "def a():" -1) + (beginning-of-line) + (point)))) (python-tests-look-at "def a():" -1) (should (= (save-excursion (python-nav-beginning-of-defun) @@ -1893,7 +1902,7 @@ class C(object): (python-tests-look-at "def b():" -1) (beginning-of-line) (point)))) - ;; Jump to a top level defun. + ;; Jump to an upper level defun. (python-tests-look-at "def b():" -1) (should (= (save-excursion (python-nav-beginning-of-defun) @@ -1902,6 +1911,14 @@ class C(object): (python-tests-look-at "def m(self):" -1) (beginning-of-line) (point)))) + (forward-line -1) + (should (= (save-excursion + (python-nav-beginning-of-defun) + (point)) + (save-excursion + (python-tests-look-at "def m(self):" -1) + (beginning-of-line) + (point)))) ;; Jump to a top level defun again. (python-tests-look-at "def m(self):" -1) (should (= (save-excursion @@ -2011,12 +2028,25 @@ class C(object): (point)))) (should (= (save-excursion (python-tests-look-at "def b():") + (forward-line -1) + (python-nav-end-of-defun) + (point)) + (save-excursion + (python-tests-look-at "def c(self):") + (forward-line -1) + (point)))) + (should (= (save-excursion + (python-tests-look-at "def b():") (python-nav-end-of-defun) (point)) (save-excursion (python-tests-look-at "def b():") (forward-line 2) (point)))) + (should (not (save-excursion + (python-tests-look-at "def a():") + (forward-line -1) + (python-nav-end-of-defun)))) (should (= (save-excursion (python-tests-look-at "def c(self):") (python-nav-end-of-defun) |