Indent while test the same way as if test (#352)

Fixes #312
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-01-20 09:42:16 -08:00
1 parent 9fc85eb30d
commit 896bb5b26d
3 files changed
+32 -1

No files matched your search

+9 -1
View File
@@ -848,7 +848,15 @@ function genericPrintNoParens(path, options, print) {
case "WhileStatement":
return concat([
"while (",
path.call(print, "test"),
group(
concat([
indent(
options.tabWidth,
concat([ softline, path.call(print, "test") ])
),
softline
])
),
")",
adjustClause(path.call(print, "body"), options)
]);
@@ -43,6 +43,27 @@ function bar(x: boolean) {
"
`;
exports[`test indent.js 1`] = `
"if (someVeryLongStringA && someVeryLongStringB && someVeryLongStringC && someVeryLongStringD) {}
while (someVeryLongStringA && someVeryLongStringB && someVeryLongStringC && someVeryLongStringD) {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (
someVeryLongStringA &&
someVeryLongStringB &&
someVeryLongStringC &&
someVeryLongStringD
) {
}
while (
someVeryLongStringA &&
someVeryLongStringB &&
someVeryLongStringC &&
someVeryLongStringD
) {
}
"
`;
exports[`test test.js 1`] = `
"class C {
m() { return new C; }
+2
View File
@@ -0,0 +1,2 @@
if (someVeryLongStringA && someVeryLongStringB && someVeryLongStringC && someVeryLongStringD) {}
while (someVeryLongStringA && someVeryLongStringB && someVeryLongStringC && someVeryLongStringD) {}