File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -1599,6 +1599,19 @@ fn main() {
1599
1599
"
1600
1600
)))
1601
1601
1602
+ (ert-deftest indent-method-chains-look-over-comment ()
1603
+ (let ((rust-indent-method-chain t )) (test-indent
1604
+ "
1605
+ fn main() {
1606
+ thing.a.do_it
1607
+ // A comment
1608
+ .aligned
1609
+ // Another comment
1610
+ .more_alignment();
1611
+ }
1612
+ "
1613
+ )))
1614
+
1602
1615
(ert-deftest indent-method-chains-comment ()
1603
1616
(let ((rust-indent-method-chain t )) (test-indent
1604
1617
"
@@ -1627,6 +1640,17 @@ fn main() { // comment here should not push next line out
1627
1640
"
1628
1641
)))
1629
1642
1643
+ (ert-deftest indent-method-chains-after-comment2 ()
1644
+ (let ((rust-indent-method-chain t )) (test-indent
1645
+ "
1646
+ fn main() {
1647
+ // Lorem ipsum lorem ipsum lorem ipsum lorem.ipsum
1648
+ foo.bar()
1649
+ }
1650
+ "
1651
+ )))
1652
+
1653
+
1630
1654
(ert-deftest test-for-issue-36-syntax-corrupted-state ()
1631
1655
" This is a test for a issue #36, which involved emacs's
1632
1656
internal state getting corrupted when actions were done in a
Original file line number Diff line number Diff line change @@ -301,6 +301,17 @@ buffer."
301
301
(when (looking-at (concat " \s *\. " rust-re-ident))
302
302
(forward-line -1 )
303
303
(end-of-line )
304
+ ; ; Keep going up (looking for a line that could contain a method chain)
305
+ ; ; while we're in a comment or on a blank line. Stop when the paren
306
+ ; ; level changes.
307
+ (let ((level (rust-paren-level)))
308
+ (while (and (or (rust-in-str-or-cmnt)
309
+ ; ; Only whitespace (or nothing) from the beginning to
310
+ ; ; the end of the line.
311
+ (looking-back " ^\s *" (point-at-bol )))
312
+ (= (rust-paren-level) level))
313
+ (forward-line -1 )
314
+ (end-of-line )))
304
315
305
316
(let
306
317
; ; skip-dot-identifier is used to position the point at the
You can’t perform that action at this time.
0 commit comments