From 5efa13a10c0f863b02ca5a89afd6c0dbe40e0e49 Mon Sep 17 00:00:00 2001 From: James Long Date: Sat, 31 Dec 2016 14:38:33 -0500 Subject: [PATCH] Never print blank lines with spaces --- src/pp.js | 5 +++++ src/printer.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pp.js b/src/pp.js index b2ee3bfb7..7b09d3f78 100644 --- a/src/pp.js +++ b/src/pp.js @@ -239,6 +239,11 @@ function print(w, doc) { } // fallthrough case MODE_BREAK: + const lastString = out[out.length - 1]; + if(lastString.match(/^\s*\n\s*$/)) { + out[out.length - 1] = "\n"; + } + if(doc.literal) { out.push("\n"); pos = 0; diff --git a/src/printer.js b/src/printer.js index 3bfe6cf70..0e697676c 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1680,7 +1680,7 @@ function printStatementSequence(path, options, print) { parts.push(stmtPrinted); if (addSpacing && !isLastStatement(stmtPath)) { - parts.push(literalline); + parts.push(hardline); } printed.push(concat(parts));