Repository: prettier/prettier (JavaScript) — Bug Fix

Issue:
Nested function wrappers indentation issue
version: 0.13.1

formatting issue:
![screen shot 2017-01-29 at 8 49 48 pm](https://cloud.githubusercontent.com/assets/23000873/22406489/03c5650c-e665-11e6-8677-32fc7dee2d7b.png)

how it should look like:
![screen shot 2017-01-29 at 8 51 43 pm](https://cloud.githubusercontent.com/assets/23000873/22406492/0bd7968e-e665-11e6-95de-3f10758e7238.png)


Discussion:
Thanks for the bug report, here's a text version and live browser to reproduce:

```js
const Settings = actionSheet(
  inject('globalsStore', 'userStore')(observer(props => {
    const shareSheet = () => {
      // production: write a share template
      Share.share({
        title: 'A title to go with the shared url ..',
        message: 'A message to go with the shared url ..',
        url: 'https://null'
      });
    };
  }))
);
```

outputs

```js
const Settings = actionSheet(
  inject("globalsStore", "userStore")(observer(props => {
      const shareSheet = () => {
        // production: write a share template
        Share.share({
          title: "A title to go with the shared url ..",
          message: "A message to go with the shared url ..",
          url: "https://null"
        });
      };
    }))
);
```

If I understand correctly, the issue is that it is indented by 4 spaces but should only be indented two spaces?

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22const%20Settings%20%3D%20actionSheet(%5Cn%20%20inject('globalsStore'%2C%20'userStore')(observer(props%20%3D%3E%20%7B%5Cn%20%20%20%20const%20shareSheet%20%3D%20()%20%3D%3E%20%7B%5Cn%20%20%20%20%20%20%2F%2F%20production%3A%20write%20a%20share%20template%5Cn%20%20%20%20%20%20Share.share(%7B%5Cn%20%20%20%20%20%20%20%20title%3A%20'A%20title%20to%20go%20with%20the%20shared%20url%20..'%2C%5Cn%20%20%20%20%20%20%20%20message%3A%20'A%20message%20to%20go%20with%20the%20shared%20url%20..'%2C%5Cn%20%20%20%20%20%20%20%20url%3A%20'https%3A%2F%2Fnull'%5Cn%20%20%20%20%20%20%7D)%3B%5Cn%20%20%20%20%7D%3B%5Cn%20%20%7D))%5Cn)%3B%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22doc%22%3Afalse%7D%7D
Minimal repro case:

```js
f(g(() => {
  a
}))
```

outputs

```js
f(g(() => {
    a;
  }));
```

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22f(g(()%20%3D%3E%20%7B%5Cn%20%20a%5Cn%7D))%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22doc%22%3Atrue%7D%7D

If you add a h() in the mix it indents by three * 2 spaces.
true, your understanding is correct, everything inside would have extra two spaces, including the render method in react. I think it would be better if there was a support for such a case.

+ thanks for the great work, oh boy 1.0.0 would be glorious! i can't even imagine.
> oh boy 1.0.0 would be glorious!

Soon, please keep sending feedback on what isn't printed correctly, we want to fix everything!

Resolving patch:
diff --git a/src/printer.js b/src/printer.js
index 236441092645..a0b50f98d847 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -1761,7 +1761,8 @@ function printArgumentsList(path, options, print) {
       ifBreak(options.trailingComma ? "," : ""),
       softline,
       ")"
-    ])
+    ]),
+    { shouldBreak: printed.some(willBreak) }
   );
 }
 


Test patch:
diff --git a/tests/break-calls/__snapshots__/jsfmt.spec.js.snap b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap
new file mode 100644
index 000000000000..f60f0bc14720
--- /dev/null
+++ b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap
@@ -0,0 +1,14 @@
+exports[`test break.js 1`] = `
+"h(f(g(() => {
+  a
+})))
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+h(
+  f(
+    g(() => {
+      a;
+    })
+  )
+);
+"
+`;
diff --git a/tests/break-calls/break.js b/tests/break-calls/break.js
new file mode 100644
index 000000000000..f7141fbccec7
--- /dev/null
+++ b/tests/break-calls/break.js
@@ -0,0 +1,3 @@
+h(f(g(() => {
+  a
+})))
diff --git a/tests/break-calls/jsfmt.spec.js b/tests/break-calls/jsfmt.spec.js
new file mode 100644
index 000000000000..989047bccc52
--- /dev/null
+++ b/tests/break-calls/jsfmt.spec.js
@@ -0,0 +1,1 @@
+run_spec(__dirname);