File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -1599,6 +1599,19 @@ fn main() {
15991599"
16001600 )))
16011601
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+
16021615(ert-deftest indent-method-chains-comment ()
16031616 (let ((rust-indent-method-chain t )) (test-indent
16041617 "
@@ -1627,6 +1640,17 @@ fn main() { // comment here should not push next line out
16271640"
16281641 )))
16291642
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+
16301654(ert-deftest test-for-issue-36-syntax-corrupted-state ()
16311655 " This is a test for a issue #36, which involved emacs's
16321656internal state getting corrupted when actions were done in a
Original file line number Diff line number Diff line change @@ -301,6 +301,17 @@ buffer."
301301 (when (looking-at (concat " \s *\. " rust-re-ident))
302302 (forward-line -1 )
303303 (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 )))
304315
305316 (let
306317 ; ; skip-dot-identifier is used to position the point at the
You can’t perform that action at this time.
0 commit comments