@decimalturn/toml-patch 3.1.2-dev → 3.2.0-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/comment-alignment.js +1 -1
- package/dist/dev/comment-ownership.js +1 -1
- package/dist/dev/cst-source.js +1 -1
- package/dist/dev/cst.js +11 -2
- package/dist/dev/cst.js.map +1 -1
- package/dist/dev/cursor.js +1 -1
- package/dist/dev/date-format.js +1 -1
- package/dist/dev/decode-utf8.js +1 -1
- package/dist/dev/diff-lite.js +123 -0
- package/dist/dev/diff-lite.js.map +1 -0
- package/dist/dev/diff.js +4 -8
- package/dist/dev/diff.js.map +1 -1
- package/dist/dev/encode-lite.js +193 -0
- package/dist/dev/encode-lite.js.map +1 -0
- package/dist/dev/escape-preference.js +33 -11
- package/dist/dev/escape-preference.js.map +1 -1
- package/dist/dev/find-by-path.js +1 -1
- package/dist/dev/formatter.js +9 -9
- package/dist/dev/formatter.js.map +1 -1
- package/dist/dev/generate.js +53 -39
- package/dist/dev/generate.js.map +1 -1
- package/dist/dev/inline-comma-space.js +1 -1
- package/dist/dev/inline-format.js +1 -1
- package/dist/dev/inline-layout.js +1 -1
- package/dist/dev/line-ending-backslash.js +1 -1
- package/dist/dev/literal-string.js +46 -0
- package/dist/dev/literal-string.js.map +1 -0
- package/dist/dev/location.js +1 -1
- package/dist/dev/parse-error.js +1 -1
- package/dist/dev/parse-js.js +49 -6
- package/dist/dev/parse-js.js.map +1 -1
- package/dist/dev/parse-string.js +1 -1
- package/dist/dev/parse-toml.js +1 -1
- package/dist/dev/patch-lite.js +4 -0
- package/dist/dev/patch-lite2.js +96 -0
- package/dist/dev/patch-lite2.js.map +1 -0
- package/dist/dev/patch.js +150 -38
- package/dist/dev/patch.js.map +1 -1
- package/dist/dev/smol-toml-date.js +61 -0
- package/dist/dev/smol-toml-date.js.map +1 -0
- package/dist/dev/to-js.js +1 -1
- package/dist/dev/to-toml.js +1 -1
- package/dist/dev/tokenizer.js +1 -1
- package/dist/dev/toml-document.js +1 -1
- package/dist/dev/toml-format.js +58 -6
- package/dist/dev/toml-format.js.map +1 -1
- package/dist/dev/toml-patch.js +1 -1
- package/dist/dev/traverse.js +1 -1
- package/dist/dev/truncate.js +1 -1
- package/dist/dev/update-order.js +1 -1
- package/dist/dev/utils.js +26 -5
- package/dist/dev/utils.js.map +1 -1
- package/dist/dev/writer.js +1 -1
- package/dist/patch-lite.d.ts +18 -0
- package/dist/toml-patch.d.ts +7 -1
- package/package.json +6 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//! @decimalturn/toml-patch v3.2.0 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
+
import { isInlineItem, isKeyValue, isValue } from "./cst.js";
|
|
3
|
+
import parseTOML from "./parse-toml.js";
|
|
4
|
+
import { hasLeadingBom } from "./decode-utf8.js";
|
|
5
|
+
import { attachSources } from "./cst-source.js";
|
|
6
|
+
import toJS from "./to-js.js";
|
|
7
|
+
import findByPath from "./find-by-path.js";
|
|
8
|
+
import diffLite, { PatchLiteError, formatPath } from "./diff-lite.js";
|
|
9
|
+
import { encodeValue } from "./encode-lite.js";
|
|
10
|
+
|
|
11
|
+
//#region src/patch-lite.ts
|
|
12
|
+
function buildDocument(items) {
|
|
13
|
+
let endLine = 1;
|
|
14
|
+
let endColumn = 0;
|
|
15
|
+
for (const item of items) {
|
|
16
|
+
const end = item.loc.end;
|
|
17
|
+
if (end.line > endLine || end.line === endLine && end.column > endColumn) {
|
|
18
|
+
endLine = end.line;
|
|
19
|
+
endColumn = end.column;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
type: "Document",
|
|
24
|
+
loc: {
|
|
25
|
+
start: {
|
|
26
|
+
line: 1,
|
|
27
|
+
column: 0
|
|
28
|
+
},
|
|
29
|
+
end: {
|
|
30
|
+
line: endLine,
|
|
31
|
+
column: endColumn
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
items
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function unwrapValue(node) {
|
|
38
|
+
if (isKeyValue(node)) return node.value;
|
|
39
|
+
if (isInlineItem(node)) {
|
|
40
|
+
if (isKeyValue(node.item)) return node.item.value;
|
|
41
|
+
return node.item;
|
|
42
|
+
}
|
|
43
|
+
return node;
|
|
44
|
+
}
|
|
45
|
+
function valueAt(root, path) {
|
|
46
|
+
let value = root;
|
|
47
|
+
for (const segment of path) value = value === null || value === void 0 ? void 0 : value[segment];
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Applies in-place value edits to an existing TOML document.
|
|
52
|
+
*
|
|
53
|
+
* This is an edit-only distribution: every change must be an edit to an
|
|
54
|
+
* existing scalar value. Added or removed keys, array length changes, array
|
|
55
|
+
* reordering, key renames and scalar/container type changes all throw before
|
|
56
|
+
* the source is mutated. All text outside the edited value spans is preserved
|
|
57
|
+
* byte for byte.
|
|
58
|
+
*
|
|
59
|
+
* @param existing - The original TOML document as a string
|
|
60
|
+
* @param updated - The updated JavaScript object with desired value changes
|
|
61
|
+
* @returns A new TOML string with only the edited values replaced
|
|
62
|
+
*/
|
|
63
|
+
function patchLite(existing, updated) {
|
|
64
|
+
if (arguments.length > 2 && arguments[2] !== void 0 && arguments[2] !== null) throw new PatchLiteError("UnsupportedOption", [], "patch-lite does not support formatting options; use patch() from the main package");
|
|
65
|
+
const hadBom = hasLeadingBom(existing);
|
|
66
|
+
const source = hadBom ? existing.slice(1) : existing;
|
|
67
|
+
const items = Array.from(parseTOML(source));
|
|
68
|
+
attachSources(items, source);
|
|
69
|
+
const existingJs = toJS(items, source, {
|
|
70
|
+
integersAsBigInt: "asNeeded",
|
|
71
|
+
temporal: false
|
|
72
|
+
});
|
|
73
|
+
const changes = diffLite(existingJs, updated);
|
|
74
|
+
if (changes.length === 0) return existing;
|
|
75
|
+
const document = buildDocument(items);
|
|
76
|
+
const replacements = [];
|
|
77
|
+
for (const change of changes) {
|
|
78
|
+
const value = unwrapValue(findByPath(document, change.path));
|
|
79
|
+
if (!isValue(value)) throw new Error(`Cannot locate a value at ${formatPath(change.path)}`);
|
|
80
|
+
const range = value.range;
|
|
81
|
+
if (!range) throw new Error(`Missing source location for value at ${formatPath(change.path)}`);
|
|
82
|
+
replacements.push({
|
|
83
|
+
start: range[0],
|
|
84
|
+
end: range[1],
|
|
85
|
+
text: encodeValue(valueAt(updated, change.path), value, change.path)
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
replacements.sort((a, b) => b.start - a.start);
|
|
89
|
+
let output = source;
|
|
90
|
+
for (const replacement of replacements) output = output.slice(0, replacement.start) + replacement.text + output.slice(replacement.end);
|
|
91
|
+
return hadBom ? "" + output : output;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
export { patchLite as default };
|
|
96
|
+
//# sourceMappingURL=patch-lite2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-lite2.js","names":[],"sources":["../../src/patch-lite.ts"],"sourcesContent":["import parseTOML from './parse-toml';\nimport toJS from './to-js';\nimport diffLite, { formatPath, PatchLiteError } from './diff-lite';\nimport { encodeValue } from './encode-lite';\nimport findByPath from './find-by-path';\nimport { hasLeadingBom, UTF8_BOM } from './decode-utf8';\nimport { attachSources } from './cst-source';\nimport {\n NodeType,\n Document,\n Block,\n TreeNode,\n Value,\n isKeyValue,\n isInlineItem,\n isValue\n} from './cst';\n\ntype Path = Array<string | number>;\n\nfunction buildDocument(items: Block[]): Document {\n let endLine = 1;\n let endColumn = 0;\n\n for (const item of items) {\n const end = item.loc.end;\n if (end.line > endLine || (end.line === endLine && end.column > endColumn)) {\n endLine = end.line;\n endColumn = end.column;\n }\n }\n\n return {\n type: NodeType.Document,\n loc: { start: { line: 1, column: 0 }, end: { line: endLine, column: endColumn } },\n items\n };\n}\n\nfunction unwrapValue(node: TreeNode): TreeNode {\n if (isKeyValue(node)) return node.value;\n if (isInlineItem(node)) {\n if (isKeyValue(node.item)) return node.item.value;\n return node.item;\n }\n return node;\n}\n\nfunction valueAt(root: any, path: Path): any {\n let value = root;\n for (const segment of path) value = value?.[segment];\n return value;\n}\n\n/**\n * Applies in-place value edits to an existing TOML document.\n *\n * This is an edit-only distribution: every change must be an edit to an\n * existing scalar value. Added or removed keys, array length changes, array\n * reordering, key renames and scalar/container type changes all throw before\n * the source is mutated. All text outside the edited value spans is preserved\n * byte for byte.\n *\n * @param existing - The original TOML document as a string\n * @param updated - The updated JavaScript object with desired value changes\n * @returns A new TOML string with only the edited values replaced\n */\nexport default function patchLite(existing: string, updated: any): string {\n // The full API takes a format object as its third argument. This build has no\n // formatting options, so dropping the argument silently would change the\n // output without saying so. Using `arguments` rather than a rest parameter\n // keeps the published two-argument signature, which already rejects the call\n // in TypeScript; the check is for JavaScript callers.\n if (arguments.length > 2 && arguments[2] !== undefined && arguments[2] !== null) {\n throw new PatchLiteError(\n 'UnsupportedOption',\n [],\n 'patch-lite does not support formatting options; use patch() from the main package'\n );\n }\n\n const hadBom = hasLeadingBom(existing);\n const source = hadBom ? existing.slice(1) : existing;\n\n const items = Array.from(parseTOML(source));\n attachSources(items, source);\n const existingJs = toJS(items, source, { integersAsBigInt: 'asNeeded', temporal: false });\n\n const changes = diffLite(existingJs, updated);\n if (changes.length === 0) return existing;\n\n const document = buildDocument(items);\n\n const replacements: Array<{ start: number; end: number; text: string }> = [];\n\n for (const change of changes) {\n const node = findByPath(document, change.path);\n const value = unwrapValue(node);\n\n if (!isValue(value)) {\n throw new Error(`Cannot locate a value at ${formatPath(change.path)}`);\n }\n\n const range = (value as Value).range;\n if (!range) {\n throw new Error(`Missing source location for value at ${formatPath(change.path)}`);\n }\n\n replacements.push({\n start: range[0],\n end: range[1],\n text: encodeValue(valueAt(updated, change.path), value, change.path)\n });\n }\n\n // Apply from the end of the source toward the beginning so earlier offsets\n // stay valid as later spans are replaced.\n replacements.sort((a, b) => b.start - a.start);\n\n let output = source;\n for (const replacement of replacements) {\n output = output.slice(0, replacement.start) + replacement.text + output.slice(replacement.end);\n }\n\n return hadBom ? UTF8_BOM + output : output;\n}\n"],"mappings":";;;;;;;;;;;AAoBA,SAAS,cAAc,OAA0B;CAC/C,IAAI,UAAU;CACd,IAAI,YAAY;CAEhB,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,MAAM,KAAK,IAAI;EACrB,IAAI,IAAI,OAAO,WAAY,IAAI,SAAS,WAAW,IAAI,SAAS,WAAY;GAC1E,UAAU,IAAI;GACd,YAAY,IAAI;EAClB;CACF;CAEA,OAAO;EACL;EACA,KAAK;GAAE,OAAO;IAAE,MAAM;IAAG,QAAQ;GAAE;GAAG,KAAK;IAAE,MAAM;IAAS,QAAQ;GAAU;EAAE;EAChF;CACF;AACF;AAEA,SAAS,YAAY,MAA0B;CAC7C,IAAI,WAAW,IAAI,GAAG,OAAO,KAAK;CAClC,IAAI,aAAa,IAAI,GAAG;EACtB,IAAI,WAAW,KAAK,IAAI,GAAG,OAAO,KAAK,KAAK;EAC5C,OAAO,KAAK;CACd;CACA,OAAO;AACT;AAEA,SAAS,QAAQ,MAAW,MAAiB;CAC3C,IAAI,QAAQ;CACZ,KAAK,MAAM,WAAW,MAAM,sDAAQ,MAAQ;CAC5C,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAwB,UAAU,UAAkB,SAAsB;CAMxE,IAAI,UAAU,SAAS,KAAK,UAAU,OAAO,UAAa,UAAU,OAAO,MACzE,MAAM,IAAI,eACR,qBACA,CAAC,GACD,mFACF;CAGF,MAAM,SAAS,cAAc,QAAQ;CACrC,MAAM,SAAS,SAAS,SAAS,MAAM,CAAC,IAAI;CAE5C,MAAM,QAAQ,MAAM,KAAK,UAAU,MAAM,CAAC;CAC1C,cAAc,OAAO,MAAM;CAC3B,MAAM,aAAa,KAAK,OAAO,QAAQ;EAAE,kBAAkB;EAAY,UAAU;CAAM,CAAC;CAExF,MAAM,UAAU,SAAS,YAAY,OAAO;CAC5C,IAAI,QAAQ,WAAW,GAAG,OAAO;CAEjC,MAAM,WAAW,cAAc,KAAK;CAEpC,MAAM,eAAoE,CAAC;CAE3E,KAAK,MAAM,UAAU,SAAS;EAE5B,MAAM,QAAQ,YADD,WAAW,UAAU,OAAO,IACZ,CAAC;EAE9B,IAAI,CAAC,QAAQ,KAAK,GAChB,MAAM,IAAI,MAAM,4BAA4B,WAAW,OAAO,IAAI,GAAG;EAGvE,MAAM,QAAS,MAAgB;EAC/B,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,wCAAwC,WAAW,OAAO,IAAI,GAAG;EAGnF,aAAa,KAAK;GAChB,OAAO,MAAM;GACb,KAAK,MAAM;GACX,MAAM,YAAY,QAAQ,SAAS,OAAO,IAAI,GAAG,OAAO,OAAO,IAAI;EACrE,CAAC;CACH;CAIA,aAAa,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;CAE7C,IAAI,SAAS;CACb,KAAK,MAAM,eAAe,cACxB,SAAS,OAAO,MAAM,GAAG,YAAY,KAAK,IAAI,YAAY,OAAO,OAAO,MAAM,YAAY,GAAG;CAG/F,OAAO,eAAoB,SAAS;AACtC"}
|
package/dist/dev/patch.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.
|
|
2
|
-
import { hasItem, hasItems, isComment, isDateTime, isDocument, isFloat, isInlineArray, isInlineItem, isInlineTable, isKeyValue, isString, isTable, isTableArray } from "./cst.js";
|
|
1
|
+
//! @decimalturn/toml-patch v3.2.0 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
|
+
import { hasItem, hasItems, isComment, isDateTime, isDocument, isFloat, isInlineArray, isInlineItem, isInlineTable, isInteger, isKeyValue, isString, isTable, isTableArray } from "./cst.js";
|
|
3
3
|
import { getSpan } from "./location.js";
|
|
4
4
|
import { IS_BARE_KEY, createNewlineScanState } from "./tokenizer.js";
|
|
5
5
|
import { DateFormatHelper } from "./date-format.js";
|
|
6
6
|
import parseTOML from "./parse-toml.js";
|
|
7
|
-
import { arraysEqual, isInteger, isObject, isTemporal, last, stableStringify, temporalToTomlString } from "./utils.js";
|
|
7
|
+
import { arraysEqual, isInteger as isInteger$1, isObject, isTemporal, last, stableStringify, temporalToTomlString } from "./utils.js";
|
|
8
8
|
import traverse from "./traverse.js";
|
|
9
9
|
import { stripLeadingBom } from "./decode-utf8.js";
|
|
10
10
|
import { TomlFormat, resolveTomlFormat } from "./toml-format.js";
|
|
@@ -447,8 +447,8 @@ function coalesceStructuralReplacements(original, updated_js, changes) {
|
|
|
447
447
|
result.push(...coalescedEdits);
|
|
448
448
|
return result;
|
|
449
449
|
}
|
|
450
|
-
function preserveEscapedKeyRaw(existingRaw, keyParts) {
|
|
451
|
-
return keyParts.map((part) => IS_BARE_KEY.test(part) ? part : `"${escapeStringContent(part, existingRaw, "singleline-basic")}"`).join(".");
|
|
450
|
+
function preserveEscapedKeyRaw(existingRaw, keyParts, escapeSequenceUpperCase = true) {
|
|
451
|
+
return keyParts.map((part) => IS_BARE_KEY.test(part) ? part : `"${escapeStringContent(part, existingRaw, "singleline-basic", escapeSequenceUpperCase)}"`).join(".");
|
|
452
452
|
}
|
|
453
453
|
function dottedKeySeparators(raw) {
|
|
454
454
|
const separators = [];
|
|
@@ -514,15 +514,98 @@ function findDottedKeyStyle(root, prefix) {
|
|
|
514
514
|
return style;
|
|
515
515
|
}
|
|
516
516
|
/**
|
|
517
|
+
* Analyzes an existing float's raw text: whether it uses exponent notation and
|
|
518
|
+
* whether its fractional part is all zeros (a "round" float such as `1.0`).
|
|
519
|
+
*/
|
|
520
|
+
function analyzeFloatStyle(raw) {
|
|
521
|
+
const expIndex = raw.search(/[eE]/);
|
|
522
|
+
const mantissa = expIndex === -1 ? raw : raw.slice(0, expIndex);
|
|
523
|
+
const dotIndex = mantissa.indexOf(".");
|
|
524
|
+
const fraction = dotIndex === -1 ? "" : mantissa.slice(dotIndex + 1);
|
|
525
|
+
return {
|
|
526
|
+
hasExponent: expIndex !== -1,
|
|
527
|
+
fractionLength: fraction.length,
|
|
528
|
+
isRound: !/[1-9]/.test(fraction)
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/** Counts the decimal places written in a float's raw text (before any exponent). */
|
|
532
|
+
function decimalPlacesOfRaw(raw) {
|
|
533
|
+
const expIndex = raw.search(/[eE]/);
|
|
534
|
+
const mantissa = expIndex === -1 ? raw : raw.slice(0, expIndex);
|
|
535
|
+
const dotIndex = mantissa.indexOf(".");
|
|
536
|
+
return dotIndex === -1 ? 0 : mantissa.length - dotIndex - 1;
|
|
537
|
+
}
|
|
538
|
+
/** Renders a value in TOML exponent notation (e.g. `1.0e11`) with at least `minimumDecimals` decimals. */
|
|
539
|
+
function renderExponentNotation(value, minimumDecimals, uppercaseExponent = false) {
|
|
540
|
+
const [mantissa, exponent] = value.toExponential().split(/[eE]/);
|
|
541
|
+
const decimals = Math.max(minimumDecimals, decimalPlacesOfRaw(mantissa));
|
|
542
|
+
return `${decimals > 0 ? Number(mantissa).toFixed(decimals) : String(Number(mantissa))}${uppercaseExponent ? "E" : "e"}${exponent.replace(/^\+/, "")}`;
|
|
543
|
+
}
|
|
544
|
+
/** Detects the radix and prefix of a prefixed integer literal (`0x`/`0o`/`0b`). */
|
|
545
|
+
function integerRadixOf(raw) {
|
|
546
|
+
if (raw.startsWith("0x")) return {
|
|
547
|
+
radix: 16,
|
|
548
|
+
prefix: "0x"
|
|
549
|
+
};
|
|
550
|
+
if (raw.startsWith("0o")) return {
|
|
551
|
+
radix: 8,
|
|
552
|
+
prefix: "0o"
|
|
553
|
+
};
|
|
554
|
+
if (raw.startsWith("0b")) return {
|
|
555
|
+
radix: 2,
|
|
556
|
+
prefix: "0b"
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
/** Extracts the underscore grouping period: the digit count of the rightmost group. */
|
|
560
|
+
function underscorePeriodOf(raw) {
|
|
561
|
+
let body = raw;
|
|
562
|
+
if (body.startsWith("+") || body.startsWith("-")) body = body.slice(1);
|
|
563
|
+
if (body.startsWith("0x") || body.startsWith("0o") || body.startsWith("0b")) body = body.slice(2);
|
|
564
|
+
const lastUnderscore = body.lastIndexOf("_");
|
|
565
|
+
return lastUnderscore === -1 ? void 0 : body.length - lastUnderscore - 1;
|
|
566
|
+
}
|
|
567
|
+
/** Inserts an underscore every `period` digits, counted from the right. */
|
|
568
|
+
function groupDigits(digits, period) {
|
|
569
|
+
if (digits.length <= period) return digits;
|
|
570
|
+
let result = "";
|
|
571
|
+
let count = 0;
|
|
572
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
573
|
+
result = digits[i] + result;
|
|
574
|
+
count++;
|
|
575
|
+
if (count === period && i > 0) {
|
|
576
|
+
result = "_" + result;
|
|
577
|
+
count = 0;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return result;
|
|
581
|
+
}
|
|
582
|
+
/** Renders an integer in the style of an existing integer literal (radix, digit case, grouping). */
|
|
583
|
+
function renderIntegerLike(value, existingRaw) {
|
|
584
|
+
const radixInfo = integerRadixOf(existingRaw);
|
|
585
|
+
const period = underscorePeriodOf(existingRaw);
|
|
586
|
+
if (radixInfo) {
|
|
587
|
+
if (typeof value === "bigint" ? value < 0n : value < 0) return void 0;
|
|
588
|
+
const uppercaseHex = radixInfo.radix === 16 && /[A-F]/.test(existingRaw);
|
|
589
|
+
let digits = value.toString(radixInfo.radix);
|
|
590
|
+
if (uppercaseHex) digits = digits.toUpperCase();
|
|
591
|
+
return radixInfo.prefix + (period ? groupDigits(digits, period) : digits);
|
|
592
|
+
}
|
|
593
|
+
if (period) {
|
|
594
|
+
const negative = typeof value === "bigint" ? value < 0n : value < 0;
|
|
595
|
+
const abs = negative ? value.toString().slice(1) : value.toString();
|
|
596
|
+
return (negative ? "-" : "") + groupDigits(abs, period);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
517
600
|
* Preserves formatting from the existing node when applying it to the replacement node.
|
|
518
601
|
* This includes multiline string formats, trailing commas, DateTime formats, etc.
|
|
519
602
|
*
|
|
520
603
|
* @param existing - The existing node with formatting to preserve
|
|
521
604
|
* @param replacement - The replacement node to apply formatting to
|
|
522
605
|
*/
|
|
523
|
-
function preserveFormatting(existing, replacement) {
|
|
606
|
+
function preserveFormatting(existing, replacement, escapeSequenceUpperCase = true) {
|
|
524
607
|
if (isString(existing) && isString(replacement)) {
|
|
525
|
-
const newString = generateString(replacement.value, existing.raw);
|
|
608
|
+
const newString = generateString(replacement.value, existing.raw, escapeSequenceUpperCase);
|
|
526
609
|
replacement.raw = newString.raw;
|
|
527
610
|
replacement.loc = newString.loc;
|
|
528
611
|
}
|
|
@@ -553,6 +636,35 @@ function preserveFormatting(existing, replacement) {
|
|
|
553
636
|
replacementFloat.raw = "+nan";
|
|
554
637
|
}
|
|
555
638
|
}
|
|
639
|
+
if (isInteger(existing) && replacement.type === "Integer") {
|
|
640
|
+
const existingInt = existing;
|
|
641
|
+
const newRaw = renderIntegerLike(replacement.value, existingInt.raw);
|
|
642
|
+
if (newRaw !== void 0) {
|
|
643
|
+
const replacementInt = replacement;
|
|
644
|
+
replacementInt.raw = newRaw;
|
|
645
|
+
replacementInt.loc.end.column = replacementInt.loc.start.column + newRaw.length;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (isFloat(existing) && (replacement.type === "Integer" || replacement.type === "Float")) {
|
|
649
|
+
const existingFloat = existing;
|
|
650
|
+
const value = replacement.value;
|
|
651
|
+
if (typeof value === "number") {
|
|
652
|
+
const { hasExponent, fractionLength, isRound } = analyzeFloatStyle(existingFloat.raw);
|
|
653
|
+
const valueIsIntegral = Number.isInteger(value) && !Object.is(value, -0);
|
|
654
|
+
const replacementDecimals = decimalPlacesOfRaw(replacement.raw);
|
|
655
|
+
let newRaw;
|
|
656
|
+
if (hasExponent && Number.isFinite(value) && !Object.is(value, -0)) {
|
|
657
|
+
const uppercaseExponent = existingFloat.raw.includes("E");
|
|
658
|
+
newRaw = renderExponentNotation(value, valueIsIntegral ? Math.max(isRound ? fractionLength : 0, replacementDecimals) : replacementDecimals, uppercaseExponent);
|
|
659
|
+
} else if (valueIsIntegral && isRound) newRaw = value.toFixed(Math.max(fractionLength, replacementDecimals));
|
|
660
|
+
if (newRaw !== void 0) {
|
|
661
|
+
const replacementFloat = replacement;
|
|
662
|
+
replacementFloat.type = "Float";
|
|
663
|
+
replacementFloat.raw = newRaw;
|
|
664
|
+
replacementFloat.loc.end.column = replacementFloat.loc.start.column + newRaw.length;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
556
668
|
if (isInlineArray(existing) && isInlineArray(replacement)) {
|
|
557
669
|
const originalHadTrailingCommas = arrayHadTrailingCommas(existing);
|
|
558
670
|
if (replacement.items.length > 0) {
|
|
@@ -679,7 +791,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
679
791
|
} else rows.push(item);
|
|
680
792
|
}
|
|
681
793
|
if (!changed) return entry;
|
|
682
|
-
const rebuilt = generateTableArray(entry.key.item.value);
|
|
794
|
+
const rebuilt = generateTableArray(entry.key.item.value, format.escapeSequenceUpperCase);
|
|
683
795
|
for (const row of rows) insert(rebuilt, rebuilt, row);
|
|
684
796
|
applyWrites(rebuilt);
|
|
685
797
|
return rebuilt;
|
|
@@ -748,7 +860,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
748
860
|
for (const k of change_path) jsValue = jsValue === null || jsValue === void 0 ? void 0 : jsValue[k];
|
|
749
861
|
if (jsValue !== void 0) {
|
|
750
862
|
const freshValue = regenerateValue(jsValue, format);
|
|
751
|
-
if (freshValue !== void 0) return generateKeyValue([...missing, ...child.key.value], freshValue);
|
|
863
|
+
if (freshValue !== void 0) return generateKeyValue([...missing, ...child.key.value], freshValue, false, format.escapeSequenceUpperCase);
|
|
752
864
|
}
|
|
753
865
|
}
|
|
754
866
|
const oldKey = child.key;
|
|
@@ -809,7 +921,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
809
921
|
else if (resolveInlineContainerLayout(isInlineArray(value) ? "array" : "table", parentDepth + 1, parentIsMultiline, contextualFormat)) value.loc.end.column = 1;
|
|
810
922
|
}
|
|
811
923
|
if (isInlineTable(parent)) {
|
|
812
|
-
const keyValue = generateKeyValue(child.item.key.value, value);
|
|
924
|
+
const keyValue = generateKeyValue(child.item.key.value, value, false, format.escapeSequenceUpperCase);
|
|
813
925
|
const regenerated = generateInlineItem(keyValue);
|
|
814
926
|
regenerated.comma = child.comma;
|
|
815
927
|
return regenerated;
|
|
@@ -865,11 +977,11 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
865
977
|
const parent_path = change.path.slice(0, -1);
|
|
866
978
|
let index = last(change.path);
|
|
867
979
|
let is_table_array = isTableArray(child);
|
|
868
|
-
if (isInteger(index) && !is_table_array && !isInteger(last(parent_path))) {
|
|
980
|
+
if (isInteger$1(index) && !is_table_array && !isInteger$1(last(parent_path))) {
|
|
869
981
|
const sibling = tryFindByPath(original, parent_path.concat(0));
|
|
870
982
|
if (sibling && isTableArray(sibling)) is_table_array = true;
|
|
871
983
|
}
|
|
872
|
-
if (is_table_array && isInteger(index) && !isInteger(last(parent_path))) {
|
|
984
|
+
if (is_table_array && isInteger$1(index) && !isInteger$1(last(parent_path))) {
|
|
873
985
|
const existingParent = tryFindByPath(original, parent_path);
|
|
874
986
|
const existingArray = existingParent && isKeyValue(existingParent) ? existingParent.value : existingParent;
|
|
875
987
|
if (existingArray && isInlineArray(existingArray)) {
|
|
@@ -899,7 +1011,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
899
1011
|
let jsValue = toJS(updated.items, "", { temporal });
|
|
900
1012
|
for (const k of change.path) jsValue = jsValue === null || jsValue === void 0 ? void 0 : jsValue[k];
|
|
901
1013
|
if (jsValue !== void 0) {
|
|
902
|
-
const freshTableArray = generateTableArray(tableArrayKey);
|
|
1014
|
+
const freshTableArray = generateTableArray(tableArrayKey, format.escapeSequenceUpperCase);
|
|
903
1015
|
const entryDoc = parseJS(jsValue, format);
|
|
904
1016
|
for (const item of entryDoc.items) insert(freshTableArray, freshTableArray, item, void 0);
|
|
905
1017
|
const prefixNestedSectionKeys = (node) => {
|
|
@@ -910,7 +1022,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
910
1022
|
const keyNode = holder.item;
|
|
911
1023
|
const fullKey = tableArrayKey.concat(keyNode.value);
|
|
912
1024
|
keyNode.value = fullKey;
|
|
913
|
-
keyNode.raw = generateKey(fullKey).raw;
|
|
1025
|
+
keyNode.raw = generateKey(fullKey, format.escapeSequenceUpperCase).raw;
|
|
914
1026
|
keyNode.loc.start.column = holder.loc.start.column + 1;
|
|
915
1027
|
keyNode.loc.end.column = keyNode.loc.start.column + keyNode.raw.length;
|
|
916
1028
|
holder.loc.end.column = keyNode.loc.start.column + keyNode.raw.length + 1;
|
|
@@ -1161,7 +1273,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1161
1273
|
if (!keyTruncated && isKeyValue(replacement)) {
|
|
1162
1274
|
if (containerParent && (isTable(containerParent) || isDocument(containerParent) || isTableArray(containerParent))) removeSiblingsExtendingPrefix(original, containerParent, existing.key.value, existing);
|
|
1163
1275
|
}
|
|
1164
|
-
preserveFormatting(existing.value, replacement.value);
|
|
1276
|
+
preserveFormatting(existing.value, replacement.value, format.escapeSequenceUpperCase);
|
|
1165
1277
|
if (containerParent) preserveAlignedInlineCommentColumn(containerParent, existing, existing.value, replacement.value);
|
|
1166
1278
|
parent = existing;
|
|
1167
1279
|
existing = existing.value;
|
|
@@ -1173,7 +1285,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1173
1285
|
const freshValue = regenerateValue(jsValue, format);
|
|
1174
1286
|
if (freshValue !== void 0) {
|
|
1175
1287
|
replacement = freshValue;
|
|
1176
|
-
preserveFormatting(existing, replacement);
|
|
1288
|
+
preserveFormatting(existing, replacement, format.escapeSequenceUpperCase);
|
|
1177
1289
|
}
|
|
1178
1290
|
}
|
|
1179
1291
|
}
|
|
@@ -1228,7 +1340,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1228
1340
|
const matchLen = truncationMatchLen(change.path, existingKeyValue.key.value, absPath ? absPath.length - existingKeyValue.key.value.length : 0);
|
|
1229
1341
|
if (matchLen > 0 && matchLen < existingKeyValue.key.value.length) {
|
|
1230
1342
|
existingKeyValue.key.value = existingKeyValue.key.value.slice(0, matchLen);
|
|
1231
|
-
existingKeyValue.key.raw = generateKey(existingKeyValue.key.value).raw;
|
|
1343
|
+
existingKeyValue.key.raw = generateKey(existingKeyValue.key.value, format.escapeSequenceUpperCase).raw;
|
|
1232
1344
|
const oldEndCol = existingKeyValue.key.loc.end.column;
|
|
1233
1345
|
const newEndCol = existingKeyValue.key.loc.start.column + existingKeyValue.key.raw.length;
|
|
1234
1346
|
const delta = newEndCol - oldEndCol;
|
|
@@ -1257,7 +1369,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1257
1369
|
}
|
|
1258
1370
|
}
|
|
1259
1371
|
}
|
|
1260
|
-
preserveFormatting(existingKeyValue.value, replacement.value);
|
|
1372
|
+
preserveFormatting(existingKeyValue.value, replacement.value, format.escapeSequenceUpperCase);
|
|
1261
1373
|
parent = existingKeyValue;
|
|
1262
1374
|
existing = existingKeyValue.value;
|
|
1263
1375
|
replacement = replacement.value;
|
|
@@ -1268,7 +1380,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1268
1380
|
const freshValue = regenerateValue(jsValue, format);
|
|
1269
1381
|
if (freshValue !== void 0) {
|
|
1270
1382
|
replacement = freshValue;
|
|
1271
|
-
preserveFormatting(existing, replacement);
|
|
1383
|
+
preserveFormatting(existing, replacement, format.escapeSequenceUpperCase);
|
|
1272
1384
|
}
|
|
1273
1385
|
}
|
|
1274
1386
|
}
|
|
@@ -1280,7 +1392,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1280
1392
|
const matchLen = truncationMatchLen(change.path, existingKV.key.value, absPath ? absPath.length - existingKV.key.value.length : 0);
|
|
1281
1393
|
if (matchLen > 0 && matchLen < existingKV.key.value.length) {
|
|
1282
1394
|
existingKV.key.value = existingKV.key.value.slice(0, matchLen);
|
|
1283
|
-
existingKV.key.raw = generateKey(existingKV.key.value).raw;
|
|
1395
|
+
existingKV.key.raw = generateKey(existingKV.key.value, format.escapeSequenceUpperCase).raw;
|
|
1284
1396
|
const oldEndCol = existingKV.key.loc.end.column;
|
|
1285
1397
|
const newEndCol = existingKV.key.loc.start.column + existingKV.key.raw.length;
|
|
1286
1398
|
const delta = newEndCol - oldEndCol;
|
|
@@ -1309,7 +1421,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1309
1421
|
}
|
|
1310
1422
|
}
|
|
1311
1423
|
}
|
|
1312
|
-
preserveFormatting(existingKV.value, replacement.item.value);
|
|
1424
|
+
preserveFormatting(existingKV.value, replacement.item.value, format.escapeSequenceUpperCase);
|
|
1313
1425
|
parent = existingKV;
|
|
1314
1426
|
existing = existingKV.value;
|
|
1315
1427
|
replacement = replacement.item.value;
|
|
@@ -1320,7 +1432,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1320
1432
|
const freshValue = regenerateValue(jsValue, format);
|
|
1321
1433
|
if (freshValue !== void 0) {
|
|
1322
1434
|
replacement = freshValue;
|
|
1323
|
-
preserveFormatting(existing, replacement);
|
|
1435
|
+
preserveFormatting(existing, replacement, format.escapeSequenceUpperCase);
|
|
1324
1436
|
}
|
|
1325
1437
|
}
|
|
1326
1438
|
}
|
|
@@ -1352,7 +1464,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1352
1464
|
removeMember(original, tableParent, existing);
|
|
1353
1465
|
commentEligibleNodes.add(freshKV);
|
|
1354
1466
|
} else {
|
|
1355
|
-
const newTable = generateTable(parentKey);
|
|
1467
|
+
const newTable = generateTable(parentKey, format.escapeSequenceUpperCase);
|
|
1356
1468
|
materialisedTables.add(newTable);
|
|
1357
1469
|
insert(original, newTable, freshKV, 0);
|
|
1358
1470
|
replace(original, tableParent, existing, newTable);
|
|
@@ -1408,7 +1520,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1408
1520
|
extendKeyWithParentAndReplace(freshKV, parentKey, existing, tableParent);
|
|
1409
1521
|
commentEligibleNodes.add(freshKV);
|
|
1410
1522
|
} else {
|
|
1411
|
-
const newTable = generateTable(parentKey);
|
|
1523
|
+
const newTable = generateTable(parentKey, format.escapeSequenceUpperCase);
|
|
1412
1524
|
materialisedTables.add(newTable);
|
|
1413
1525
|
insert(original, newTable, freshKV, 0);
|
|
1414
1526
|
replace(original, tableParent, existing, newTable);
|
|
@@ -1435,7 +1547,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1435
1547
|
}
|
|
1436
1548
|
if (isInlineItem(existing) && isInlineItem(replacement)) {
|
|
1437
1549
|
if (isString(existing.item) && isString(replacement.item)) {
|
|
1438
|
-
preserveFormatting(existing.item, replacement.item);
|
|
1550
|
+
preserveFormatting(existing.item, replacement.item, format.escapeSequenceUpperCase);
|
|
1439
1551
|
replacement.loc = {
|
|
1440
1552
|
start: { ...replacement.item.loc.start },
|
|
1441
1553
|
end: { ...replacement.item.loc.end }
|
|
@@ -1486,7 +1598,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1486
1598
|
aotKeyHolder.type = "TableKey";
|
|
1487
1599
|
const aotKey = hasItem(aotKeyHolder) ? aotKeyHolder.item : aotKeyHolder;
|
|
1488
1600
|
aotKey.value = parentPath;
|
|
1489
|
-
aotKey.raw = preserveEscapedKeyRaw(aotKey.raw, aotKey.value);
|
|
1601
|
+
aotKey.raw = preserveEscapedKeyRaw(aotKey.raw, aotKey.value, format.escapeSequenceUpperCase);
|
|
1490
1602
|
aotKey.loc.end.column = aotKey.loc.start.column + aotKey.raw.length;
|
|
1491
1603
|
aotKeyHolder.loc.end.column = aotKeyHolder.loc.start.column + aotKey.raw.length + 2;
|
|
1492
1604
|
aotNode.loc.end.line = aotKeyHolder.loc.end.line;
|
|
@@ -1509,7 +1621,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1509
1621
|
let value = rawUpdated;
|
|
1510
1622
|
for (const k of parentPath) value = value === null || value === void 0 ? void 0 : value[k];
|
|
1511
1623
|
if (isObject(value) && Object.keys(value).length === 0) {
|
|
1512
|
-
const emptyTable = generateTable(parentPath);
|
|
1624
|
+
const emptyTable = generateTable(parentPath, format.escapeSequenceUpperCase);
|
|
1513
1625
|
materialisedTables.add(emptyTable);
|
|
1514
1626
|
const insertIdx = firstIndex >= 0 ? Math.min(firstIndex, original.items.length) : original.items.length;
|
|
1515
1627
|
applyWrites(original);
|
|
@@ -1529,7 +1641,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1529
1641
|
let value = rawUpdated;
|
|
1530
1642
|
for (const k of change.path.slice(0, -1)) value = value === null || value === void 0 ? void 0 : value[k];
|
|
1531
1643
|
if (isObject(value) && Object.keys(value).length === 0) {
|
|
1532
|
-
const emptyTable = generateTable(cstParentPath);
|
|
1644
|
+
const emptyTable = generateTable(cstParentPath, format.escapeSequenceUpperCase);
|
|
1533
1645
|
materialisedTables.add(emptyTable);
|
|
1534
1646
|
const insertIdx = firstPrefixIndex >= 0 ? Math.min(firstPrefixIndex, original.items.length) : original.items.length;
|
|
1535
1647
|
applyWrites(original);
|
|
@@ -1565,7 +1677,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1565
1677
|
const keyHolder = table.key;
|
|
1566
1678
|
const key = hasItem(keyHolder) ? keyHolder.item : keyHolder;
|
|
1567
1679
|
key.value = cstParentPath;
|
|
1568
|
-
key.raw = preserveEscapedKeyRaw(key.raw, key.value);
|
|
1680
|
+
key.raw = preserveEscapedKeyRaw(key.raw, key.value, format.escapeSequenceUpperCase);
|
|
1569
1681
|
key.loc.end.column = key.loc.start.column + key.raw.length;
|
|
1570
1682
|
keyHolder.loc.end.column = keyHolder.loc.start.column + key.raw.length + 2;
|
|
1571
1683
|
table.loc.end.line = keyHolder.loc.end.line;
|
|
@@ -1679,7 +1791,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1679
1791
|
let value = rawUpdated;
|
|
1680
1792
|
for (const k of parentPath) value = value === null || value === void 0 ? void 0 : value[k];
|
|
1681
1793
|
if (isObject(value) && Object.keys(value).length === 0) {
|
|
1682
|
-
const emptyTable = generateTable(cstParentKey);
|
|
1794
|
+
const emptyTable = generateTable(cstParentKey, format.escapeSequenceUpperCase);
|
|
1683
1795
|
materialisedTables.add(emptyTable);
|
|
1684
1796
|
const insertIdx = nodeIndex >= 0 ? Math.min(nodeIndex, original.items.length) : original.items.length;
|
|
1685
1797
|
applyWrites(original);
|
|
@@ -1757,7 +1869,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1757
1869
|
return;
|
|
1758
1870
|
}
|
|
1759
1871
|
const tableKey = isAotEntry ? container.key.item.value.concat(relativePrefix) : isTable(container) ? container.key.item.value.concat(relativePrefix) : relativePrefix;
|
|
1760
|
-
const emptyTable = generateTable(tableKey);
|
|
1872
|
+
const emptyTable = generateTable(tableKey, format.escapeSequenceUpperCase);
|
|
1761
1873
|
materialisedTables.add(emptyTable);
|
|
1762
1874
|
let insertIdx = nodeIndex >= 0 ? nodeIndex : original.items.length;
|
|
1763
1875
|
if (isAotEntry) {
|
|
@@ -1877,7 +1989,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1877
1989
|
const segmentIndex = sourcePath.length - 1;
|
|
1878
1990
|
const originalRaw = key.raw;
|
|
1879
1991
|
key.value[segmentIndex] = change.to;
|
|
1880
|
-
key.raw = preserveEscapedKeyRaw(key.raw, key.value);
|
|
1992
|
+
key.raw = preserveEscapedKeyRaw(key.raw, key.value, format.escapeSequenceUpperCase);
|
|
1881
1993
|
preserveDottedKeySpacing(key, originalRaw);
|
|
1882
1994
|
key.loc.end.column = key.loc.start.column + key.raw.length;
|
|
1883
1995
|
return;
|
|
@@ -1897,7 +2009,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1897
2009
|
const segmentIndex = fullSourcePath.length - 1;
|
|
1898
2010
|
const originalRaw = parentKey.raw;
|
|
1899
2011
|
parentKey.value[segmentIndex] = change.to;
|
|
1900
|
-
parentKey.raw = preserveEscapedKeyRaw(parentKey.raw, parentKey.value);
|
|
2012
|
+
parentKey.raw = preserveEscapedKeyRaw(parentKey.raw, parentKey.value, format.escapeSequenceUpperCase);
|
|
1901
2013
|
preserveDottedKeySpacing(parentKey, originalRaw);
|
|
1902
2014
|
parentKey.loc.end.column = parentKey.loc.start.column + parentKey.raw.length;
|
|
1903
2015
|
return;
|
|
@@ -1905,7 +2017,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1905
2017
|
if (isKeyValue(parent) && isKeyValue(replacement) && parentKey.value.length <= fullSourcePath.length && arraysEqual(parentKey.value, fullSourcePath.slice(fullSourcePath.length - parentKey.value.length))) {
|
|
1906
2018
|
const oldKeyRaw = parentKey.raw;
|
|
1907
2019
|
parentKey.value[parentKey.value.length - 1] = change.to;
|
|
1908
|
-
parentKey.raw = preserveEscapedKeyRaw(parentKey.raw, parentKey.value);
|
|
2020
|
+
parentKey.raw = preserveEscapedKeyRaw(parentKey.raw, parentKey.value, format.escapeSequenceUpperCase);
|
|
1909
2021
|
parentKey.loc.end.column = parentKey.loc.start.column + parentKey.raw.length;
|
|
1910
2022
|
const keyWidthDelta = parentKey.raw.length - oldKeyRaw.length;
|
|
1911
2023
|
if (keyWidthDelta > 0) {
|
|
@@ -1923,7 +2035,7 @@ function applyChanges(original, updated, changes, format, temporal = false, comm
|
|
|
1923
2035
|
}
|
|
1924
2036
|
throw new Error(`Cannot rename "${parentKey.raw}" to "${replacementKey.raw}": the replacement key has ${replacementKey.value.length} segment(s) where the existing key has ${parentKey.value.length}, so one cannot be substituted for the other.`);
|
|
1925
2037
|
}
|
|
1926
|
-
replacementKey.raw = preserveEscapedKeyRaw(parentKey.raw, replacementKey.value);
|
|
2038
|
+
replacementKey.raw = preserveEscapedKeyRaw(parentKey.raw, replacementKey.value, format.escapeSequenceUpperCase);
|
|
1927
2039
|
preserveDottedKeySpacing(replacementKey, parentKey.raw);
|
|
1928
2040
|
replacementKey.loc.end.column = replacementKey.loc.start.column + replacementKey.raw.length;
|
|
1929
2041
|
const keyOwner = hasItem(parentHolder) ? parentHolder : parent;
|
|
@@ -2123,7 +2235,7 @@ function handleStructuralEdit(original, updated, change, format, temporal, comme
|
|
|
2123
2235
|
const oldRaw = row.key.raw;
|
|
2124
2236
|
const dotted = tableKey.concat(row.key.value);
|
|
2125
2237
|
row.key.value = dotted;
|
|
2126
|
-
row.key.raw = generateKey(dotted).raw;
|
|
2238
|
+
row.key.raw = generateKey(dotted, format.escapeSequenceUpperCase).raw;
|
|
2127
2239
|
const delta = row.key.raw.length - oldRaw.length;
|
|
2128
2240
|
row.key.loc.end.column = row.key.loc.start.column + row.key.raw.length;
|
|
2129
2241
|
row.equals += delta;
|
|
@@ -2415,7 +2527,7 @@ function convertNestedInlineTablesToMultiline(table, original, format) {
|
|
|
2415
2527
|
if (isKeyValue(item) && isInlineTable(item.value)) {
|
|
2416
2528
|
const nestedTableKey = [...currentTable.key.item.value, ...item.key.value];
|
|
2417
2529
|
if (calculateTableDepth(nestedTableKey) < (format.inlineTableStart ?? 1) && format.inlineTableStart !== 0) {
|
|
2418
|
-
const separateTable = generateTable(nestedTableKey);
|
|
2530
|
+
const separateTable = generateTable(nestedTableKey, format.escapeSequenceUpperCase);
|
|
2419
2531
|
for (const inlineItem of item.value.items) if (isInlineItem(inlineItem) && isKeyValue(inlineItem.item)) insert(original, separateTable, inlineItem.item, void 0);
|
|
2420
2532
|
currentTable.items.splice(i, 1);
|
|
2421
2533
|
postInlineItemRemovalAdjustment(currentTable);
|
|
@@ -2440,7 +2552,7 @@ function convertNestedInlineTablesToMultiline(table, original, format) {
|
|
|
2440
2552
|
*/
|
|
2441
2553
|
function convertInlineTableToSeparateSection(child, parent, original, format) {
|
|
2442
2554
|
const nestedTableKey = [...parent.key.item.value, ...child.key.value];
|
|
2443
|
-
const separateTable = generateTable(nestedTableKey);
|
|
2555
|
+
const separateTable = generateTable(nestedTableKey, format.escapeSequenceUpperCase);
|
|
2444
2556
|
if (isInlineTable(child.value)) {
|
|
2445
2557
|
for (const inlineItem of child.value.items) if (isInlineItem(inlineItem) && isKeyValue(inlineItem.item)) insert(original, separateTable, inlineItem.item, void 0);
|
|
2446
2558
|
}
|