diff --git a/src/document/printer.js b/src/document/printer.js index 430771c95..131553eb3 100644 --- a/src/document/printer.js +++ b/src/document/printer.js @@ -18,7 +18,7 @@ import { DOC_TYPE_BREAK_PARENT, } from "./constants.js"; import { fill, indent, hardlineWithoutBreakParent } from "./builders.js"; -import { getDocParts, getDocType } from "./utils.js"; +import { getDocParts, getDocType, propagateBreaks } from "./utils.js"; import InvalidDocError from "./invalid-doc-error.js"; /** @typedef {typeof MODE_BREAK | typeof MODE_FLAT} Mode */ @@ -313,6 +313,8 @@ function printDocToString(doc, options) { const lineSuffix = []; let printedCursorCount = 0; + propagateBreaks(doc); + while (cmds.length > 0) { const { ind, mode, doc } = cmds.pop(); switch (getDocType(doc)) { diff --git a/src/main/ast-to-doc.js b/src/main/ast-to-doc.js index b881db8c1..d149bd103 100644 --- a/src/main/ast-to-doc.js +++ b/src/main/ast-to-doc.js @@ -1,6 +1,5 @@ import AstPath from "../common/ast-path.js"; import { cursor, label } from "../document/builders.js"; -import { propagateBreaks } from "../document/utils.js"; import { printComments } from "./comments/print.js"; import { printEmbeddedLanguages } from "./multiparser.js"; import createPrintPreCheckFunction from "./create-print-pre-check-function.js"; @@ -55,8 +54,6 @@ async function printAstToDoc(ast, options) { embeds ); - propagateBreaks(doc); - return doc; function mainPrint(selector, args) {