;; Allow up to two consecutive docstrings only.
(>=
2
- (progn
+ (let (last-backward-sexp-point)
(while (save-excursion
(python-nav-backward-sexp)
(setq backward-sexp-point (point))
(and (= indentation (current-indentation))
- (not (bobp)) ; Prevent infloop.
+ ;; Make sure we're always moving point.
+ ;; If we get stuck in the same position
+ ;; on consecutive loop iterations,
+ ;; bail out.
+ (prog1 (not (eql last-backward-sexp-point
+ backward-sexp-point))
+ (setq last-backward-sexp-point
+ backward-sexp-point))
(looking-at-p
(concat "[uU]?[rR]?"
(python-rx string-delimiter)))))
(line-beginning-position) (line-end-position))
"abcdef")))))
+(ert-deftest python-bob-infloop-avoid ()
+ "Test that strings at BOB don't confuse syntax analysis. Bug#24905"
+ (python-tests-with-temp-buffer
+ " \"\n"
+ (goto-char (point-min))
+ (font-lock-fontify-buffer)))
+
\f
;;; Shell integration