about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2017-04-06 21:17:22 +1200
committerNick Cameron <ncameron@mozilla.com>2017-04-06 21:17:22 +1200
commitee9daade3597dc6e94855ab9e90fc9ebfbea6a1f (patch)
tree94864cadabcb325a88162b010da8b3cb7346d622
parenta7183766b95d43700ddc583b9e9f5d4bcfa91e58 (diff)
Fix a bug with overlong function calls
-rw-r--r--src/expr.rs13
-rw-r--r--tests/source/fn-simple.rs9
-rw-r--r--tests/target/fn-simple.rs10
3 files changed, 30 insertions, 2 deletions
diff --git a/src/expr.rs b/src/expr.rs
index 04634e2645e..2723c4099c1 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1715,10 +1715,19 @@ fn rewrite_call_inner<R>(context: &RewriteContext,
         }
     }
 
+    let one_line_width = shape.width.checked_sub(used_width + 2);
+    let one_line_width = match one_line_width {
+        Some(olw) => olw,
+        None => return Err(Ordering::Greater),
+    };
+    let one_line_shape = Shape {
+        width: one_line_width,
+        ..nested_shape
+    };
     let tactic =
         definitive_tactic(&item_vec,
                           ListTactic::LimitedHorizontalVertical(context.config.fn_call_width),
-                          nested_shape.width);
+                          one_line_width);
 
     // Replace the stub with the full overflowing last argument if the rewrite
     // succeeded and its first line fits with the other arguments.
@@ -1741,7 +1750,7 @@ fn rewrite_call_inner<R>(context: &RewriteContext,
         } else {
             context.config.trailing_comma
         },
-        shape: nested_shape,
+        shape: one_line_shape,
         ends_with_newline: false,
         config: context.config,
     };
diff --git a/tests/source/fn-simple.rs b/tests/source/fn-simple.rs
index 1764266718e..e11df34ad86 100644
--- a/tests/source/fn-simple.rs
+++ b/tests/source/fn-simple.rs
@@ -44,3 +44,12 @@ unsafe fn generic_call(cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal,
 }
 
 pub fn start_export_thread<C: CryptoSchemee + 'static>(database: &Database, crypto_scheme: &C, block_size: usize, source_path: &Path) -> BonzoResult<mpsc::Consumer<'static, FileInstruction>> {}
+
+pub fn waltz(cwd: &Path) -> CliAssert {
+    {
+        {
+            formatted_comment = rewrite_comment(comment, block_style, width, offset, formatting_fig);
+        }
+    }
+
+}
diff --git a/tests/target/fn-simple.rs b/tests/target/fn-simple.rs
index 4bcbbd6613f..697fe21501c 100644
--- a/tests/target/fn-simple.rs
+++ b/tests/target/fn-simple.rs
@@ -73,3 +73,13 @@ pub fn start_export_thread<C: CryptoSchemee + 'static>
      source_path: &Path)
      -> BonzoResult<mpsc::Consumer<'static, FileInstruction>> {
 }
+
+pub fn waltz(cwd: &Path) -> CliAssert {
+    {
+        {
+            formatted_comment =
+                rewrite_comment(comment, block_style, width, offset, formatting_fig);
+        }
+    }
+
+}