Fix formatting with --range-start / --range-end (#5632)

This change avoids collapsing an already-formatted range into a single
overlong line when --range-start / --range-end are provided.

Fixes: #4923
This commit is contained in:
lhchavez authored and Lucas Duailibe committed 2018-12-17 10:59:20 -02:00
1 parent 6a45924379
commit 911d6c88e5
3 files changed
+37 -1

No files matched your search

+1 -1
View File
@@ -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
);
@@ -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"]
+8
View File
@@ -0,0 +1,8 @@
function ugly() {
const dictWithSeveralEntries = {
key: "value",
<<<PRETTIER_RANGE_START>>> anotherKey: "another value",
firstNumber: 1,
secondNumber: 2<<<PRETTIER_RANGE_END>>>
};
}