Move propagateBreaks to printDocToString (#14466)

This commit is contained in:
fisker Cheung authored and GitHub committed 2023-03-07 20:42:14 +08:00
1 parent 9d328e6306
commit 57b37a3c27
2 files changed
+3 -4

No files matched your search

+3 -1
View File
@@ -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)) {
-3
View File
@@ -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) {