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: #4923master
parent
6a45924379
commit
911d6c88e5
|
@ -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"]
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
function ugly() {
|
||||
const dictWithSeveralEntries = {
|
||||
key: "value",
|
||||
<<<PRETTIER_RANGE_START>>> anotherKey: "another value",
|
||||
firstNumber: 1,
|
||||
secondNumber: 2<<<PRETTIER_RANGE_END>>>
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue