|
54 | 54 | /// .baz();
|
55 | 55 | /// ```
|
56 | 56 | ///
|
57 |
| -/// `chain_indent` dictates how the rest of the chain is aligned. This only seems |
58 |
| -/// to have an effect if the first non-root part of the chain is put on a |
59 |
| -/// newline, otherwise we align the dots: |
60 |
| -/// ``` |
61 |
| -/// foo.bar |
62 |
| -/// .baz() |
63 |
| -/// ``` |
| 57 | +/// `chain_indent` dictates how the rest of the chain is aligned. |
64 | 58 | /// If the first item in the chain is a block expression, we align the dots with
|
65 | 59 | /// the braces.
|
66 |
| -/// |
67 |
| -/// Otherwise: |
68 | 60 | /// Visual:
|
69 | 61 | /// ```
|
70 |
| -/// let a = foo(aaa, bbb) |
71 |
| -/// .bar |
72 |
| -/// .baz() |
| 62 | +/// let a = foo.bar |
| 63 | +/// .baz() |
| 64 | +/// .qux |
73 | 65 | /// ```
|
74 |
| -/// Visual seems to be a tab indented from the indent of the whole expression. |
75 | 66 | /// Inherit:
|
76 | 67 | /// ```
|
77 |
| -/// let a = foo(aaa, bbb) |
78 |
| -/// .bar |
| 68 | +/// let a = foo.bar |
79 | 69 | /// .baz()
|
| 70 | +/// .qux |
80 | 71 | /// ```
|
81 | 72 | /// Tabbed:
|
82 | 73 | /// ```
|
83 |
| -/// let a = foo(aaa, bbb) |
84 |
| -/// .bar |
| 74 | +/// let a = foo.bar |
85 | 75 | /// .baz()
|
| 76 | +/// .qux |
86 | 77 | /// ```
|
87 | 78 | /// `chains_overflow_last` applies only to chains where the last item is a
|
88 | 79 | /// method call. Usually, any line break in a chain sub-expression causes the
|
@@ -127,7 +118,7 @@ pub fn rewrite_chain(expr: &ast::Expr,
|
127 | 118 | } else if parent_rewrite.contains('\n') {
|
128 | 119 | (chain_indent(context, parent_block_indent.block_indent(context.config)), false)
|
129 | 120 | } else {
|
130 |
| - (hacked_chain_indent(context, offset + Indent::new(0, parent_rewrite.len())), false) |
| 121 | + (chain_indent_newline(context, offset + Indent::new(0, parent_rewrite.len())), false) |
131 | 122 | };
|
132 | 123 |
|
133 | 124 | let max_width = try_opt!((width + offset.width()).checked_sub(indent.width()));
|
@@ -259,9 +250,9 @@ fn chain_indent(context: &RewriteContext, offset: Indent) -> Indent {
|
259 | 250 | }
|
260 | 251 | }
|
261 | 252 |
|
262 |
| -// Temporary hack - ignores visual indenting because this function should be |
263 |
| -// called where it is not possible to use visual indentation. |
264 |
| -fn hacked_chain_indent(context: &RewriteContext, _offset: Indent) -> Indent { |
| 253 | +// Ignores visual indenting because this function should be called where it is |
| 254 | +// not possible to use visual indentation because we are starting on a newline. |
| 255 | +fn chain_indent_newline(context: &RewriteContext, _offset: Indent) -> Indent { |
265 | 256 | match context.config.chain_indent {
|
266 | 257 | BlockIndentStyle::Inherit => context.block_indent,
|
267 | 258 | BlockIndentStyle::Visual | BlockIndentStyle::Tabbed => {
|
|
0 commit comments