Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c34bb3

Browse files
committed
(py-goto-beginning-of-tqs): When searching backwards for the matching
delimiter, watch out for backslash escaped delimiters. Also use = instead of eq for character comparison (because a character is = to it's integer value, but not eq to it).
1 parent 08a8a35 commit 3c34bb3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Misc/python-mode.el

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,12 +2864,16 @@ If nesting level is zero, return nil."
28642864
"Go to the beginning of the triple quoted string we find ourselves in.
28652865
DELIM is the TQS string delimiter character we're searching backwards
28662866
for."
2867-
(let ((skip (and delim (make-string 1 delim))))
2867+
(let ((skip (and delim (make-string 1 delim)))
2868+
(continue t))
28682869
(when skip
28692870
(save-excursion
2870-
(py-safe (search-backward skip))
2871-
(if (and (eq (char-before) delim)
2872-
(eq (char-before (1- (point))) delim))
2871+
(while continue
2872+
(py-safe (search-backward skip))
2873+
(setq continue (and (not (bobp))
2874+
(= (char-before) ?\\))))
2875+
(if (and (= (char-before) delim)
2876+
(= (char-before (1- (point))) delim))
28732877
(setq skip (make-string 3 delim))))
28742878
;; we're looking at a triple-quoted string
28752879
(py-safe (search-backward skip)))))

0 commit comments

Comments
 (0)