about summary refs log tree commit diff
path: root/src/expr.rs
diff options
context:
space:
mode:
authorMarcus Klaas <mail@marcusklaas.nl>2015-10-12 21:14:12 +0200
committerMarcus Klaas <mail@marcusklaas.nl>2015-10-12 21:14:12 +0200
commite6af5d2c835ea1a4d84517218336fa718f297107 (patch)
treeae11a0d431e530cc1e572f35977f1b07708b631c /src/expr.rs
parent4bc43f6f35a7ae46c38e7395783c0d8c49e2c6f0 (diff)
Use visual block indentation for array literals
Diffstat (limited to 'src/expr.rs')
-rw-r--r--src/expr.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/expr.rs b/src/expr.rs
index 7cc3e7fadf1..4a2b318c6ad 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -256,6 +256,8 @@ pub fn rewrite_array<'a, I>(expr_iter: I,
     where I: Iterator<Item = &'a ast::Expr>
 {
     // 2 for brackets;
+    let offset = offset + 1;
+    let inner_context = &RewriteContext { block_indent: offset, ..*context };
     let max_item_width = try_opt!(width.checked_sub(2));
     let items = itemize_list(context.codemap,
                              expr_iter,
@@ -263,7 +265,7 @@ pub fn rewrite_array<'a, I>(expr_iter: I,
                              |item| item.span.lo,
                              |item| item.span.hi,
                              // 1 = [
-                             |item| item.rewrite(context, max_item_width, offset + 1),
+                             |item| item.rewrite(&inner_context, max_item_width, offset),
                              span_after(span, "[", context.codemap),
                              span.hi)
                     .collect::<Vec<_>>();
@@ -283,7 +285,7 @@ pub fn rewrite_array<'a, I>(expr_iter: I,
         tactic: tactic,
         separator: ",",
         trailing_separator: SeparatorTactic::Never,
-        indent: offset + 1,
+        indent: offset,
         width: max_item_width,
         ends_with_newline: false,
         config: context.config,