Fix Python mode error caused by incorrect indentation
* lisp/progmodes/python.el (python-indent--calculate-indentation): Guard against negative indentation. (Bug #65870) * test/lisp/progmodes/python-tests.el (python-indent-badly-indented-block-end): New test.
This commit is contained in:
parent
d7be9fdbc0
commit
c03cafba39
2 changed files with 10 additions and 1 deletions
|
@ -1819,7 +1819,7 @@ possibilities can be narrowed to specific indentation points."
|
|||
(`(:after-block-end . ,start)
|
||||
;; Subtract one indentation level.
|
||||
(goto-char start)
|
||||
(- (current-indentation) python-indent-offset))
|
||||
(max 0 (- (current-indentation) python-indent-offset)))
|
||||
(`(:at-dedenter-block-start . ,_)
|
||||
;; List all possible indentation levels from opening blocks.
|
||||
(let ((opening-block-start-points
|
||||
|
|
|
@ -2149,6 +2149,15 @@ def test_re(string):
|
|||
(python-tests-look-at "else:")
|
||||
(should (= (python-indent-calculate-indentation) 4))))
|
||||
|
||||
(ert-deftest python-indent-badly-indented-block-end ()
|
||||
"Test BUG 65870 regression."
|
||||
(python-tests-with-temp-buffer
|
||||
"
|
||||
return
|
||||
"
|
||||
(goto-char (point-max))
|
||||
(should (= (python-indent-calculate-indentation) 0))))
|
||||
|
||||
|
||||
;;; Filling
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue