File tree 3 files changed +48
-1
lines changed
std/fixtures/fmt/indented_call_chains
3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -2584,11 +2584,19 @@ impl Generator {
2584
2584
Node :: IndentNext ( nodes) if wrap. is_enabled ( ) => {
2585
2585
self . pending_indents += 1 ;
2586
2586
2587
+ let before = self . pending_indents ;
2588
+
2587
2589
for n in nodes {
2588
2590
self . node ( n, wrap) ;
2589
2591
}
2590
2592
2591
- self . indent -= 2 ;
2593
+ // If we didn't encounter a new line, reset the state. If we do,
2594
+ // we have to dedent the lines that follow.
2595
+ if self . pending_indents == before {
2596
+ self . pending_indents -= 1 ;
2597
+ } else {
2598
+ self . indent -= 2 ;
2599
+ }
2592
2600
}
2593
2601
Node :: IndentNext ( nodes) => {
2594
2602
for n in nodes {
Original file line number Diff line number Diff line change
1
+ fn foo {
2
+ aaa.aaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.cccc('aaaaaaaa').cccc('aaa').cccc(aaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb)
3
+ 100
4
+ }
5
+
6
+ fn bar {
7
+ aaa.aaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.cccc('aaaaaaaa').cccc('aaa').cccc(aaaa)
8
+ 100
9
+ }
10
+
11
+ fn baz {
12
+ # line
13
+ }
Original file line number Diff line number Diff line change
1
+ fn foo {
2
+ aaa
3
+ .aaaaaaaaaaaaaaaaa
4
+ .bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
5
+ .cccc('aaaaaaaa')
6
+ .cccc('aaa')
7
+ .cccc(
8
+ aaaa,
9
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
10
+ )
11
+ 100
12
+ }
13
+
14
+ fn bar {
15
+ aaa
16
+ .aaaaaaaaaaaaaaaaa
17
+ .bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
18
+ .cccc('aaaaaaaa')
19
+ .cccc('aaa')
20
+ .cccc(aaaa)
21
+ 100
22
+ }
23
+
24
+ fn baz {
25
+ # line
26
+ }
You can’t perform that action at this time.
0 commit comments