(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
(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)))))
(python-tests-look-at
"if request.user.is_authenticated():" -1)))))
+(ert-deftest python-nav-forward-block-2 ()
+ (python-tests-with-temp-buffer
+ "
+if True:
+ pass
+"
+ (python-tests-look-at "if True:")
+ (should (not (save-excursion (python-nav-forward-block))))
+ (should (not (save-excursion (python-nav-forward-block -1))))
+ (forward-char)
+ (should (not (save-excursion (python-nav-forward-block))))
+ (should (= (save-excursion (python-nav-forward-block -1))
+ (progn
+ (end-of-line)
+ (python-tests-look-at "if True:" -1))))))
+
(ert-deftest python-nav-forward-sexp-1 ()
(python-tests-with-temp-buffer
"