Remove placeholder from doc.builders.cursor (#13312)
This commit is contained in:
1 parent
49cd8be0b8
commit
e28ae2670c
2 files changed
+7
-10
No files matched your search
@@ -208,7 +208,7 @@ const softline = { type: DOC_TYPE_LINE, soft: true };
|
||||
const hardline = [hardlineWithoutBreakParent, breakParent];
|
||||
const literalline = [literallineWithoutBreakParent, breakParent];
|
||||
|
||||
const cursor = { type: DOC_TYPE_CURSOR, placeholder: Symbol("cursor") };
|
||||
const cursor = { type: DOC_TYPE_CURSOR };
|
||||
|
||||
/**
|
||||
* @param {Doc} sep
|
||||
|
||||
@@ -18,12 +18,7 @@ import {
|
||||
DOC_TYPE_LABEL,
|
||||
DOC_TYPE_BREAK_PARENT,
|
||||
} from "./constants.js";
|
||||
import {
|
||||
fill,
|
||||
cursor,
|
||||
indent,
|
||||
hardlineWithoutBreakParent,
|
||||
} from "./builders.js";
|
||||
import { fill, indent, hardlineWithoutBreakParent } from "./builders.js";
|
||||
import { getDocParts, getDocType } from "./utils.js";
|
||||
import InvalidDocError from "./invalid-doc-error.js";
|
||||
|
||||
@@ -36,6 +31,8 @@ const MODE_BREAK = Symbol("MODE_BREAK");
|
||||
/** @type {unique symbol} */
|
||||
const MODE_FLAT = Symbol("MODE_FLAT");
|
||||
|
||||
const CURSOR_PLACEHOLDER = Symbol("cursor");
|
||||
|
||||
function rootIndent() {
|
||||
return { value: "", length: 0, queue: [] };
|
||||
}
|
||||
@@ -316,7 +313,7 @@ function printDocToString(doc, options) {
|
||||
}
|
||||
|
||||
case DOC_TYPE_CURSOR:
|
||||
out.push(cursor.placeholder);
|
||||
out.push(CURSOR_PLACEHOLDER);
|
||||
break;
|
||||
|
||||
case DOC_TYPE_INDENT:
|
||||
@@ -605,10 +602,10 @@ function printDocToString(doc, options) {
|
||||
}
|
||||
}
|
||||
|
||||
const cursorPlaceholderIndex = out.indexOf(cursor.placeholder);
|
||||
const cursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER);
|
||||
if (cursorPlaceholderIndex !== -1) {
|
||||
const otherCursorPlaceholderIndex = out.indexOf(
|
||||
cursor.placeholder,
|
||||
CURSOR_PLACEHOLDER,
|
||||
cursorPlaceholderIndex + 1
|
||||
);
|
||||
const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
|
||||
|
||||
Reference in new issue
Block a user