Unwrap fill with single part in cleanDoc (#13350)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-05-27 06:24:09 +08:00
1 parent 4025d3e226
commit 8adab11211
2 files changed
+10 -3

No files matched your search

+9 -2
View File
@@ -266,11 +266,18 @@ function stripTrailingHardline(doc) {
function cleanDocFn(doc) {
switch (getDocType(doc)) {
case DOC_TYPE_FILL:
if (doc.parts.every((part) => part === "")) {
case DOC_TYPE_FILL: {
const { parts } = doc;
if (parts.every((part) => part === "")) {
return "";
}
if (parts.length === 1) {
return parts[0];
}
break;
}
case DOC_TYPE_GROUP:
if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
return "";
@@ -14,7 +14,7 @@ describe("cleanDoc", () => {
[
"fill",
[fill([""]), fill([]), fill(["1"]), fill(["2", line, "3"])],
[fill(["1"]), fill(["2", line, "3"])],
["1", fill(["2", line, "3"])],
],
["nested group", group(group("_")), group("_")],
[