diff --git a/src/main/ast-to-doc.js b/src/main/ast-to-doc.js index 8fa5cd65..899b100f 100644 --- a/src/main/ast-to-doc.js +++ b/src/main/ast-to-doc.js @@ -78,7 +78,7 @@ function printAstToDoc(ast, options, alignmentSize = 0) { // Add a hardline to make the indents take effect // It should be removed in index.js format() doc = addAlignmentToDoc( - docUtils.removeLines(concat([hardline, doc])), + concat([hardline, doc]), alignmentSize, options.tabWidth ); diff --git a/tests/range/__snapshots__/jsfmt.spec.js.snap b/tests/range/__snapshots__/jsfmt.spec.js.snap index cae5bdfc..adcd96db 100644 --- a/tests/range/__snapshots__/jsfmt.spec.js.snap +++ b/tests/range/__snapshots__/jsfmt.spec.js.snap @@ -88,6 +88,34 @@ function ugly ( {a=1, b = 2 } ) { ================================================================================ `; +exports[`large-dict.js 1`] = ` +====================================options===================================== +parsers: ["flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +function ugly() { + const dictWithSeveralEntries = { + key: "value", + anotherKey: "another value", + firstNumber: 1, + secondNumber: 2 + }; +} + +=====================================output===================================== +function ugly() { + const dictWithSeveralEntries = { + key: "value", + anotherKey: "another value", + firstNumber: 1, + secondNumber: 2 + }; +} + +================================================================================ +`; + exports[`module-export1.js 1`] = ` ====================================options===================================== parsers: ["flow", "typescript"] diff --git a/tests/range/large-dict.js b/tests/range/large-dict.js new file mode 100644 index 00000000..78647b73 --- /dev/null +++ b/tests/range/large-dict.js @@ -0,0 +1,8 @@ +function ugly() { + const dictWithSeveralEntries = { + key: "value", +<<>> anotherKey: "another value", + firstNumber: 1, + secondNumber: 2<<>> + }; +}