@@ -365,11 +365,8 @@ buffer."
365
365
((nth 3 (syntax-ppss ))
366
366
(let*
367
367
((string-begin-pos (nth 8 (syntax-ppss )))
368
- (end-of-prev-line-pos (when (> (line-number-at-pos ) 1 )
369
- (save-excursion
370
- (forward-line -1 )
371
- (end-of-line )
372
- (point )))))
368
+ (end-of-prev-line-pos (unless (rust--same-line-p (point ) (point-min ))
369
+ (line-end-position 0 ))))
373
370
(when
374
371
(and
375
372
; ; If the string begins with an "r" it's a raw string and
@@ -389,7 +386,7 @@ buffer."
389
386
390
387
; ; Indent to the same level as the previous line, or the
391
388
; ; start of the string if the previous line starts the string
392
- (if (= ( line-number-at-pos end-of-prev-line-pos) ( line-number-at-pos string-begin-pos) )
389
+ (if (rust--same-line-p end-of-prev-line-pos string-begin-pos)
393
390
; ; The previous line is the start of the string.
394
391
; ; If the backslash is the only character after the
395
392
; ; string beginning, indent to the next indent
@@ -530,6 +527,11 @@ buffer."
530
527
(indent-line-to indent)
531
528
(save-excursion (indent-line-to indent))))))
532
529
530
+ (defun rust--same-line-p (pos1 pos2 )
531
+ " Return non-nil if POS1 and POS2 are on the same line."
532
+ (save-excursion (= (progn (goto-char pos1) (line-end-position ))
533
+ (progn (goto-char pos2) (line-end-position )))))
534
+
533
535
534
536
; ; Font-locking definitions and helpers
535
537
(defconst rust-mode-keywords
0 commit comments