1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Fix `python-nav-forward-block' moving backward under certain conditions

* lisp/progmodes/python.el (python-nav-forward-block): Add check
for not moving backward (bug#57223).
This commit is contained in:
kobarity 2022-08-15 16:30:23 +02:00 committed by Lars Ingebrigtsen
parent 5025b2566e
commit 0d3aebec01
2 changed files with 20 additions and 2 deletions

View file

@ -1822,7 +1822,8 @@ backward to previous block."
(or arg (setq arg 1))
(let ((block-start-regexp
(python-rx line-start (* whitespace) block-start))
(starting-pos (point)))
(starting-pos (point))
(orig-arg arg))
(while (> arg 0)
(python-nav-end-of-statement)
(while (and
@ -1836,7 +1837,8 @@ backward to previous block."
(python-syntax-context-type)))
(setq arg (1+ arg)))
(python-nav-beginning-of-statement)
(if (not (looking-at (python-rx block-start)))
(if (or (and (> orig-arg 0) (< (point) starting-pos))
(not (looking-at (python-rx block-start))))
(and (goto-char starting-pos) nil)
(and (not (= (point) starting-pos)) (point-marker)))))