Fix off by one error in python-mode assertion (Bug#30964)

* lisp/progmodes/python.el (python-nav-end-of-statement): Don't assert
that string-start is strictly greater than last-string-end, because
the string end is a position outside of the string and may therefore
be the same as the following string's start.
* test/lisp/progmodes/python-tests.el (python-nav-end-of-statement-2):
New test.
This commit is contained in:
Noam Postavsky 2018-06-02 16:22:17 -04:00
parent 92b609c572
commit 05345babc9
2 changed files with 7 additions and 1 deletions

View file

@ -1518,7 +1518,7 @@ of the statement."
;; are somehow out of whack. This has been
;; observed when using `syntax-ppss' during
;; narrowing.
(cl-assert (> string-start last-string-end)
(cl-assert (>= string-start last-string-end)
:show-args
"\
Overlapping strings detected (start=%d, last-end=%d)")

View file

@ -2004,6 +2004,12 @@ string
(python-util-forward-comment -1)
(point))))))
(ert-deftest python-nav-end-of-statement-2 ()
"Test the string overlap assertion (Bug#30964)."
(python-tests-with-temp-buffer
"'\n''\n"
(python-nav-end-of-statement)))
(ert-deftest python-nav-forward-statement-1 ()
(python-tests-with-temp-buffer
"