Fix indentation for multi-line block start in Python mode

* lisp/progmodes/python.el
(python-info-dedenter-opening-block-positions): Fix for multi-line
block start.
* test/lisp/progmodes/python-tests.el
(python-info-dedenter-opening-block-positions-6): New test. (Bug#59009)
This commit is contained in:
kobarity 2022-11-07 22:24:44 +09:00 committed by Eli Zaretskii
parent f7694c80d3
commit f8df45f853
2 changed files with 18 additions and 0 deletions

View file

@ -5377,6 +5377,7 @@ likely an invalid python file."
;; block and the current line, otherwise it
;; is not an opening block.
(save-excursion
(python-nav-end-of-statement)
(forward-line)
(let ((no-back-indent t))
(save-match-data

View file

@ -5592,6 +5592,23 @@ else:
(equal (list (python-tests-look-at "else:" -1 t))
(python-info-dedenter-opening-block-positions)))))
(ert-deftest python-info-dedenter-opening-block-positions-6 ()
"Test multiline block start."
(python-tests-with-temp-buffer
"
def func():
if (
cond1 or
cond2
):
something()
else
"
(python-tests-look-at "else\n")
(should
(equal (list (python-tests-look-at "if (" -1 t))
(python-info-dedenter-opening-block-positions)))))
(ert-deftest python-info-dedenter-opening-block-message-1 ()
"Test dedenters inside strings are ignored."
(python-tests-with-temp-buffer