From ca814b79044221606bcc8114bf9d781409201202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 21 Dec 2022 18:16:28 +0100 Subject: [PATCH] patch comma line breaks based on original data --- src/language-css/printer-postcss.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index e3f13b04b0cd..8d194e30f284 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -905,12 +905,17 @@ function genericPrint(path, options, print) { } if (!node.open) { + const origValueText = options.originalText.slice( + locStart(path.getParentNode(2)), + locEnd(path.getParentNode(2)) + ); + const forceHardLine = origValueText.includes("\n"); const printed = path.map(print, "groups"); - const res = [hardline]; + const res = forceHardLine ? [hardline] : []; for (let i = 0; i < printed.length; i++) { if (i !== 0) { - res.push([",", hardline]); + res.push([",", forceHardLine ? hardline : line]); } res.push(printed[i]); }