diff --git a/src/document/doc-printer.js b/src/document/doc-printer.js index 4f27b0444..1886571aa 100644 --- a/src/document/doc-printer.js +++ b/src/document/doc-printer.js @@ -18,18 +18,26 @@ function makeIndent(ind, options) { return generateInd(ind, { type: "indent" }, options); } -function makeAlign(ind, n, options) { - return n === -Infinity - ? ind.root || rootIndent() - : n < 0 - ? generateInd(ind, { type: "dedent" }, options) - : !n - ? ind - : n.type === "root" - ? { ...ind, root: ind } - : typeof n === "string" - ? generateInd(ind, { type: "stringAlign", n }, options) - : generateInd(ind, { type: "numberAlign", n }, options); +function makeAlign(indent, n, options) { + if (n === -Infinity) { + return indent.root || rootIndent(); + } + + if (n < 0) { + return generateInd(indent, { type: "dedent" }, options); + } + + if (!n) { + return indent; + } + + if (n.type === "root") { + return { ...indent, root: indent }; + } + + const alignType = typeof n === "string" ? "stringAlign" : "numberAlign"; + + return generateInd(indent, { type: alignType, n }, options); } function generateInd(ind, newPart, options) {