@decimalturn/toml-patch 3.1.0-dev → 3.1.1-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 +62 -62
- package/dist/dev/comment-ownership.js.map +1 -1
- package/dist/dev/cst-source.js +1 -1
- package/dist/dev/cst.js +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.js +1 -1
- package/dist/dev/escape-preference.js +1 -1
- package/dist/dev/find-by-path.js +1 -1
- package/dist/dev/formatter.js +1 -1
- package/dist/dev/generate.js +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/location.js +30 -3
- package/dist/dev/location.js.map +1 -1
- package/dist/dev/parse-error.js +1 -1
- package/dist/dev/parse-js.js +1 -1
- package/dist/dev/parse-string.js +1 -1
- package/dist/dev/parse-toml.js +18 -10
- package/dist/dev/parse-toml.js.map +1 -1
- package/dist/dev/patch.js +27 -27
- package/dist/dev/patch.js.map +1 -1
- 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 +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 +21 -21
- package/dist/dev/update-order.js.map +1 -1
- package/dist/dev/utils.js +1 -1
- package/dist/dev/writer.js +1 -1
- package/dist/toml-patch.d.ts +10 -10
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import { hasItems, isComment, isInlineArray, isInlineItem, isInlineTable, isKeyValue, isTable, isTableArray } from "./cst.js";
|
|
3
3
|
import { getSpan } from "./location.js";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import { hasItems, isComment, isDocument, isInlineArray, isInlineItem, isInlineTable, isKeyValue, isString, isTable, isTableArray } from "./cst.js";
|
|
3
3
|
import { clonePosition } from "./location.js";
|
|
4
4
|
import { last } from "./utils.js";
|
|
@@ -51,7 +51,7 @@ function hasInlineCommentAfterValue(comment) {
|
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* True when the comment looks enough like a KV to act as a barrier in
|
|
54
|
-
*
|
|
54
|
+
* scanGroups. Broader than `isCommentedOutEntry`: also matches lines with
|
|
55
55
|
* an inline trailing comment (`# key = val # note`) and lines whose value
|
|
56
56
|
* part is short enough not to be obvious prose (≤3 words after `=`).
|
|
57
57
|
*/
|
|
@@ -79,7 +79,7 @@ function commentedOutFirstKey(comment) {
|
|
|
79
79
|
* OUTER key-value (e.g. `data = [x, y] # note`) would otherwise appear to
|
|
80
80
|
* fall "inside" a nested single-line array's own line range too, wrongly
|
|
81
81
|
* treating an unrelated comment as hoisted from inside it. The element-level
|
|
82
|
-
* ownership machinery below (
|
|
82
|
+
* ownership machinery below (resolveInlineElementGroups / removeMember's and
|
|
83
83
|
* moveInlineElement's InlineTable/InlineArray branches) must only engage
|
|
84
84
|
* here, matching writer.ts's own `isMultilineInlineContainer` convention.
|
|
85
85
|
*/
|
|
@@ -92,20 +92,20 @@ function getMemberKey(member) {
|
|
|
92
92
|
if (isInlineItem(member) && isKeyValue(member.item)) return member.item.key.value[0];
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
|
-
* The rule scan shared by
|
|
95
|
+
* The rule scan shared by resolveGroups (Document/Table/TableArray, where members
|
|
96
96
|
* and comments are already interleaved in one items array) and
|
|
97
|
-
*
|
|
97
|
+
* resolveInlineElementGroups (InlineTable/InlineArray, where they are merged from
|
|
98
98
|
* two different arrays first — see that function). `items` must already be in
|
|
99
99
|
* ascending line order; a `Comment` node is a comment, anything else is a member.
|
|
100
100
|
*/
|
|
101
|
-
function
|
|
102
|
-
const
|
|
101
|
+
function scanGroups(items, initialLastMemberEndLine, isEligibleForLeading, memberKey = getMemberKey) {
|
|
102
|
+
const groups = [];
|
|
103
103
|
let lastMemberEndLine = initialLastMemberEndLine;
|
|
104
|
-
let
|
|
104
|
+
let currentMemberGroup;
|
|
105
105
|
let pendingRun = [];
|
|
106
106
|
const flushPendingAsPinned = () => {
|
|
107
107
|
if (!pendingRun.length) return;
|
|
108
|
-
|
|
108
|
+
groups.push({
|
|
109
109
|
kind: "pinned",
|
|
110
110
|
items: pendingRun,
|
|
111
111
|
startLine: pendingRun[0].loc.start.line,
|
|
@@ -116,10 +116,10 @@ function scanSlots(items, initialLastMemberEndLine, isEligibleForLeading, member
|
|
|
116
116
|
for (const item of items) {
|
|
117
117
|
if (isComment(item)) {
|
|
118
118
|
if (item.loc.start.line <= lastMemberEndLine) {
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} else
|
|
119
|
+
if (currentMemberGroup) {
|
|
120
|
+
currentMemberGroup.items.push(item);
|
|
121
|
+
currentMemberGroup.endLine = Math.max(currentMemberGroup.endLine, item.loc.end.line);
|
|
122
|
+
} else groups.push({
|
|
123
123
|
kind: "pinned",
|
|
124
124
|
items: [item],
|
|
125
125
|
startLine: item.loc.start.line,
|
|
@@ -150,7 +150,7 @@ function scanSlots(items, initialLastMemberEndLine, isEligibleForLeading, member
|
|
|
150
150
|
}
|
|
151
151
|
if (lastBarrierIdx >= 0) {
|
|
152
152
|
const pinned = pendingRun.splice(0, lastBarrierIdx + 1);
|
|
153
|
-
|
|
153
|
+
groups.push({
|
|
154
154
|
kind: "pinned",
|
|
155
155
|
items: pinned,
|
|
156
156
|
startLine: pinned[0].loc.start.line,
|
|
@@ -162,36 +162,36 @@ function scanSlots(items, initialLastMemberEndLine, isEligibleForLeading, member
|
|
|
162
162
|
pendingRun = [];
|
|
163
163
|
} else flushPendingAsPinned();
|
|
164
164
|
}
|
|
165
|
-
const
|
|
166
|
-
const
|
|
165
|
+
const groupItems = [...leading, item];
|
|
166
|
+
const group = {
|
|
167
167
|
kind: "member",
|
|
168
168
|
member: item,
|
|
169
169
|
key: memberKey(item),
|
|
170
|
-
items:
|
|
171
|
-
startLine:
|
|
170
|
+
items: groupItems,
|
|
171
|
+
startLine: groupItems[0].loc.start.line,
|
|
172
172
|
endLine: item.loc.end.line
|
|
173
173
|
};
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
groups.push(group);
|
|
175
|
+
currentMemberGroup = group;
|
|
176
176
|
lastMemberEndLine = item.loc.end.line;
|
|
177
177
|
}
|
|
178
178
|
flushPendingAsPinned();
|
|
179
|
-
return
|
|
179
|
+
return groups;
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
|
-
* Partitions a container's items into ownership
|
|
182
|
+
* Partitions a container's items into ownership groups, in document order.
|
|
183
183
|
* Pure: does not mutate the tree.
|
|
184
184
|
*
|
|
185
185
|
* @param isEligibleForLeading - optional predicate; members that fail it cannot
|
|
186
186
|
* acquire leading comments via R2. Used by callers that have just inserted
|
|
187
|
-
* nodes which must not adopt a preceding
|
|
187
|
+
* nodes which must not adopt a preceding block.
|
|
188
188
|
*/
|
|
189
|
-
function
|
|
189
|
+
function resolveGroups(container, isEligibleForLeading = () => true, memberKey = getMemberKey) {
|
|
190
190
|
const initialLastMemberEndLine = isDocument(container) ? 0 : container.key.loc.end.line;
|
|
191
|
-
return
|
|
191
|
+
return scanGroups(container.items, initialLastMemberEndLine, isEligibleForLeading, memberKey);
|
|
192
192
|
}
|
|
193
193
|
/**
|
|
194
|
-
* The element-level analogue of
|
|
194
|
+
* The element-level analogue of resolveGroups, for a multi-line InlineTable or
|
|
195
195
|
* InlineArray. Unlike Document/Table/TableArray, an inline container's own
|
|
196
196
|
* `.items` can never hold a Comment (InlineTableItem/InlineArrayItem are both
|
|
197
197
|
* InlineItem<...>) — the parser hoists interior comments out into the
|
|
@@ -199,16 +199,16 @@ function resolveSlots(container, isEligibleForLeading = () => true, memberKey =
|
|
|
199
199
|
* plan doc). `hostItems` is that enclosing container's `.items`; this merges
|
|
200
200
|
* the comments physically inside `container`'s line range back in with
|
|
201
201
|
* `container.items` (sorted into true reading order) before running the same
|
|
202
|
-
* scan
|
|
202
|
+
* scan resolveGroups uses.
|
|
203
203
|
*
|
|
204
204
|
* There is no R6 analogue for bare array elements (they aren't `key = value`
|
|
205
205
|
* shaped), but nothing here suppresses R6 for an InlineArray's own comments —
|
|
206
|
-
* see docs/
|
|
206
|
+
* see docs/Comment-Ownership.md for why that's an accepted, untested edge
|
|
207
207
|
* case rather than a deliberate rule.
|
|
208
208
|
*/
|
|
209
|
-
function
|
|
209
|
+
function resolveInlineElementGroups(container, hostItems) {
|
|
210
210
|
const interiorComments = hostItems.filter((item) => isComment(item) && (item.loc.start.line > container.loc.start.line || item.loc.start.line === container.loc.start.line && item.loc.start.column >= container.loc.start.column) && (item.loc.end.line < container.loc.end.line || item.loc.end.line === container.loc.end.line && item.loc.end.column <= container.loc.end.column));
|
|
211
|
-
return
|
|
211
|
+
return scanGroups([...container.items, ...interiorComments].sort((a, b) => a.loc.start.line - b.loc.start.line || a.loc.start.column - b.loc.start.column), container.loc.start.line, () => true);
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* Finds the nearest Document/Table/TableArray ancestor whose OWN `.items`
|
|
@@ -264,7 +264,7 @@ function findHostContainer(root, target) {
|
|
|
264
264
|
* comment that visually introduces the next [table]/[[array]] block is
|
|
265
265
|
* physically stored as a trailing item of the PREVIOUS block, because the
|
|
266
266
|
* parser consumes everything up to the next `[` into the current table
|
|
267
|
-
* (src/parse-toml.ts:517-524). This re-parents such
|
|
267
|
+
* (src/parse-toml.ts:517-524). This re-parents such blocks into Document.items,
|
|
268
268
|
* immediately before the block they visually belong to.
|
|
269
269
|
*
|
|
270
270
|
* Mutates the tree; loc-preserving, so serialized output is unchanged. NOTE:
|
|
@@ -294,24 +294,24 @@ function normalizeSectionComments(document) {
|
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
/**
|
|
297
|
-
* R5, computed lazily: if `container`'s trailing comment
|
|
297
|
+
* R5, computed lazily: if `container`'s trailing comment block is R2-adjacent
|
|
298
298
|
* to `nextBlock` (and not R6-dead), returns it — these are the comments a
|
|
299
299
|
* removal of `nextBlock` must take along, even though they physically live
|
|
300
300
|
* in `container.items`. Returns undefined otherwise.
|
|
301
301
|
*/
|
|
302
302
|
function trailingOwnedRun(container, nextBlock) {
|
|
303
|
-
const
|
|
304
|
-
if (!
|
|
305
|
-
const runItems =
|
|
306
|
-
const adjacent =
|
|
303
|
+
const lastGroup = last(resolveGroups(container));
|
|
304
|
+
if (!lastGroup || lastGroup.kind !== "pinned") return void 0;
|
|
305
|
+
const runItems = lastGroup.items;
|
|
306
|
+
const adjacent = lastGroup.endLine + 1 === nextBlock.loc.start.line;
|
|
307
307
|
const allDead = runItems.every(isCommentedOutEntry);
|
|
308
308
|
if (!adjacent || allDead) return void 0;
|
|
309
309
|
return runItems;
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
312
|
* Removes `member` from `parent.items` along with every comment it owns
|
|
313
|
-
* (leading
|
|
314
|
-
* when `member` is a [table]/[[array]] block, any trailing comment
|
|
313
|
+
* (leading block and trailing comments — see resolveGroups), plus,
|
|
314
|
+
* when `member` is a [table]/[[array]] block, any trailing comment block the
|
|
315
315
|
* parser filed under the PRECEDING sibling table but which R5 assigns to
|
|
316
316
|
* `member` instead. Falls back to a plain removal when `parent` isn't a
|
|
317
317
|
* container the ownership model applies to (e.g. InlineTable/InlineArray).
|
|
@@ -326,16 +326,16 @@ function removeMember(root, parent, member) {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
if (isDocument(parent) || isTable(parent) || isTableArray(parent)) {
|
|
329
|
-
const
|
|
330
|
-
if (
|
|
331
|
-
const memberIndex =
|
|
329
|
+
const group = resolveGroups(parent).find((s) => s.member === member);
|
|
330
|
+
if (group) {
|
|
331
|
+
const memberIndex = group.items.indexOf(member);
|
|
332
332
|
for (let i = 0; i <= memberIndex; i++) {
|
|
333
|
-
const item =
|
|
333
|
+
const item = group.items[i];
|
|
334
334
|
if (!parent.items.includes(item)) continue;
|
|
335
335
|
remove(root, parent, item);
|
|
336
336
|
}
|
|
337
|
-
for (let i = memberIndex + 1; i <
|
|
338
|
-
const item =
|
|
337
|
+
for (let i = memberIndex + 1; i < group.items.length; i++) {
|
|
338
|
+
const item = group.items[i];
|
|
339
339
|
const idx = parent.items.indexOf(item);
|
|
340
340
|
if (idx < 0) continue;
|
|
341
341
|
parent.items.splice(idx, 1);
|
|
@@ -346,17 +346,17 @@ function removeMember(root, parent, member) {
|
|
|
346
346
|
if (isMultilineInlineContainer(parent) && isDocument(root)) {
|
|
347
347
|
const hostContainer = findHostContainer(root, parent);
|
|
348
348
|
if (hostContainer) {
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
351
|
-
const comments =
|
|
349
|
+
const group = resolveInlineElementGroups(parent, hostContainer.items).find((s) => s.member === member);
|
|
350
|
+
if (group) {
|
|
351
|
+
const comments = group.items.filter((item) => item !== member);
|
|
352
352
|
for (const comment of comments) {
|
|
353
353
|
const idx = hostContainer.items.indexOf(comment);
|
|
354
354
|
if (idx < 0) continue;
|
|
355
355
|
hostContainer.items.splice(idx, 1);
|
|
356
356
|
}
|
|
357
357
|
if (comments.length) {
|
|
358
|
-
member.loc.start =
|
|
359
|
-
member.loc.end = last(
|
|
358
|
+
member.loc.start = group.items[0].loc.start;
|
|
359
|
+
member.loc.end = last(group.items).loc.end;
|
|
360
360
|
}
|
|
361
361
|
remove(root, parent, member, hostContainer.items);
|
|
362
362
|
applyWrites(root);
|
|
@@ -369,11 +369,11 @@ function removeMember(root, parent, member) {
|
|
|
369
369
|
/**
|
|
370
370
|
* Relocates `node` (an element of `parent`, an InlineTable/InlineArray) from
|
|
371
371
|
* its current position to `toIndex`, carrying its own owned comments along
|
|
372
|
-
* (see
|
|
372
|
+
* (see resolveInlineElementGroups) rather than leaving them at their old
|
|
373
373
|
* absolute position — which is what plain remove()+insert() does, and why a
|
|
374
374
|
* Move on a commented inline array can misplace a comment onto an unrelated
|
|
375
|
-
* line (see "
|
|
376
|
-
* docs/
|
|
375
|
+
* line (see "Elements inside multi-line arrays and inline tables" in
|
|
376
|
+
* docs/Comment-Ownership.md).
|
|
377
377
|
*
|
|
378
378
|
* It isn't enough to protect only `node`'s own comments: writer.remove()'s
|
|
379
379
|
* per-container "orphaned comment" cleanup reasons purely by absolute line
|
|
@@ -390,7 +390,7 @@ function moveInlineElement(root, parent, node, toIndex) {
|
|
|
390
390
|
if (isMultilineInlineContainer(parent) && isDocument(root)) {
|
|
391
391
|
const hostContainer = findHostContainer(root, parent);
|
|
392
392
|
if (hostContainer) {
|
|
393
|
-
const
|
|
393
|
+
const groups = resolveInlineElementGroups(parent, hostContainer.items);
|
|
394
394
|
{
|
|
395
395
|
const items = parent.items;
|
|
396
396
|
let run = 1;
|
|
@@ -460,23 +460,23 @@ function moveInlineElement(root, parent, node, toIndex) {
|
|
|
460
460
|
} else if (hasItems(item)) collectAnchored(item, firstLine);
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
|
-
for (const
|
|
464
|
-
if (
|
|
465
|
-
const comments =
|
|
466
|
-
if (
|
|
463
|
+
for (const group of groups) {
|
|
464
|
+
if (group.kind !== "member" || !group.member) continue;
|
|
465
|
+
const comments = group.items.filter((item) => item !== group.member);
|
|
466
|
+
if (group.member === node) {
|
|
467
467
|
nodeOwnStart = clonePosition(node.loc.start);
|
|
468
468
|
nodeOwnEnd = clonePosition(node.loc.end);
|
|
469
469
|
if (isInlineItem(node)) nodeInnerEnd = clonePosition(node.item.loc.end);
|
|
470
470
|
collectAnchored(isInlineItem(node) ? node.item : node, nodeOwnStart.line);
|
|
471
471
|
if (comments.length) {
|
|
472
|
-
node.loc.start = clonePosition(
|
|
473
|
-
node.loc.end = clonePosition(last(
|
|
472
|
+
node.loc.start = clonePosition(group.items[0].loc.start);
|
|
473
|
+
node.loc.end = clonePosition(last(group.items).loc.end);
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
if (!comments.length) continue;
|
|
477
477
|
detached.push({
|
|
478
|
-
owner:
|
|
479
|
-
ownerOriginalStart: clonePosition(
|
|
478
|
+
owner: group.member,
|
|
479
|
+
ownerOriginalStart: clonePosition(group.member.loc.start),
|
|
480
480
|
comments
|
|
481
481
|
});
|
|
482
482
|
for (const comment of comments) {
|
|
@@ -656,5 +656,5 @@ function moveInlineElement(root, parent, node, toIndex) {
|
|
|
656
656
|
}
|
|
657
657
|
|
|
658
658
|
//#endregion
|
|
659
|
-
export { IS_COMMENTED_OUT_HEADER, IS_COMMENTED_OUT_KEY_VALUE, findHostContainer, isCommentedOutEntry, moveInlineElement, normalizeSectionComments, removeMember,
|
|
659
|
+
export { IS_COMMENTED_OUT_HEADER, IS_COMMENTED_OUT_KEY_VALUE, findHostContainer, isCommentedOutEntry, moveInlineElement, normalizeSectionComments, removeMember, resolveGroups, resolveInlineElementGroups };
|
|
660
660
|
//# sourceMappingURL=comment-ownership.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-ownership.js","names":[],"sources":["../../src/comment-ownership.ts"],"sourcesContent":["import {\n Document,\n Table,\n TableArray,\n InlineTable,\n InlineArray,\n KeyValue,\n TreeNode,\n Comment,\n isComment,\n isKeyValue,\n isTable,\n isTableArray,\n isDocument,\n isInlineTable,\n isInlineArray,\n isInlineItem,\n isString,\n hasItems,\n InlineItem\n} from './cst';\nimport { last } from './utils';\nimport { clonePosition } from './location';\nimport { remove, insert, shiftNode, applyWrites, recalcContainerEnd, perLine, getExitOffsets, addExitOffset, Root } from './writer';\n\n// See docs/PLAN-Comment-Ownership.md for the full model (rules R1-R6).\n\n// R6 — commented-out entries are not owned.\n// Segment charset matches IS_BARE_KEY (/^[\\w-]+$/, src/tokenizer.ts:22).\nconst KEY_SEGMENT = String.raw`(?:[\\w-]+|\"[^\"]*\"|'[^']*')`;\n\n/** `# key = ...`, `# a.b.c = ...`, `# \"quoted key\" = ...` */\nexport const IS_COMMENTED_OUT_KEY_VALUE =\n new RegExp(String.raw`^#\\s*${KEY_SEGMENT}(?:\\s*\\.\\s*${KEY_SEGMENT})*\\s*=`);\n\n/** A value after `=` in a commented-out KV: a quoted string, number, boolean,\n * date-like token, or a single bare word. Multi-word prose (e.g.\n * `# key = 1 is something to consider`) does NOT match, so the comment\n * is treated as alive prose rather than a dead entry. */\nconst VALUE_TOKEN = String.raw`(?:\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*'|\"\"\"[\\s\\S]*?\"\"\"|'''[\\s\\S]*?'''|[^\\s#]+)`;\n\n/** Full-line match: `# key = value` where value is a single token. */\nconst IS_PURE_COMMENTED_OUT_KV =\n new RegExp(String.raw`^#\\s*${KEY_SEGMENT}(?:\\s*\\.\\s*${KEY_SEGMENT})*\\s*=\\s*${VALUE_TOKEN}\\s*$`);\n\n/** `# [table]`, `# [[array]]`, `# [a.b]` */\nexport const IS_COMMENTED_OUT_HEADER =\n new RegExp(String.raw`^#\\s*\\[\\[?\\s*${KEY_SEGMENT}(?:\\s*\\.\\s*${KEY_SEGMENT})*\\s*\\]\\]?\\s*$`);\n\nexport function isCommentedOutEntry(comment: Comment): boolean {\n return IS_PURE_COMMENTED_OUT_KV.test(comment.raw) || IS_COMMENTED_OUT_HEADER.test(comment.raw);\n}\n\n/**\n * True when a `#` appears outside of quotes after the `=` in a\n * commented-out-KV line — i.e. the line has an inline trailing comment\n * (`# key = val # note`). `#` inside a quoted value (e.g.\n * `# key = \"a # b\" extra`) is NOT an inline comment.\n */\nfunction hasInlineCommentAfterValue(comment: Comment): boolean {\n const eqIdx = comment.raw.indexOf('=');\n if (eqIdx < 0) return false;\n let inDQuote = false;\n let inSQuote = false;\n for (let i = eqIdx + 1; i < comment.raw.length; i++) {\n const ch = comment.raw[i];\n if (ch === '\\\\') { i++; continue; }\n if (!inSQuote && ch === '\"') { inDQuote = !inDQuote; continue; }\n if (!inDQuote && ch === \"'\") { inSQuote = !inSQuote; continue; }\n if (!inDQuote && !inSQuote && ch === '#') return true;\n }\n return false;\n}\n\n/**\n * True when the comment looks enough like a KV to act as a barrier in\n * scanSlots. Broader than `isCommentedOutEntry`: also matches lines with\n * an inline trailing comment (`# key = val # note`) and lines whose value\n * part is short enough not to be obvious prose (≤3 words after `=`).\n */\nfunction looksLikeKV(comment: Comment): boolean {\n if (isCommentedOutEntry(comment)) return true;\n if (!IS_COMMENTED_OUT_KEY_VALUE.test(comment.raw)) return false;\n // Has an inline comment after the value: `# key = val # note`\n if (hasInlineCommentAfterValue(comment)) return true;\n // Short value: `# key = a few words` (not running prose)\n const afterEq = comment.raw.replace(/^[^=]*=\\s*/, '');\n const wordCount = afterEq.split(/\\s+/).filter(Boolean).length;\n return wordCount <= 3;\n}\n\n/** Extract the first key segment from a commented-out KV like `# key = val`. */\nfunction commentedOutFirstKey(comment: Comment): string | undefined {\n const m = comment.raw.match(IS_COMMENTED_OUT_KEY_VALUE);\n if (!m) return undefined;\n // Strip `#` prefix and everything from `=` onward, then trim.\n // For dotted keys like `# a.b.c = val`, this gives `a.b.c`.\n let key = m[0].replace(/^#\\s*/, '').replace(/\\s*=.*$/, '').trim();\n // Take only the first segment for comparison with the KV's own first key.\n const dot = key.indexOf('.');\n if (dot >= 0) key = key.substring(0, dot);\n // Strip quotes if present\n if ((key.startsWith('\"') && key.endsWith('\"')) || (key.startsWith(\"'\") && key.endsWith(\"'\"))) {\n key = key.slice(1, -1);\n }\n return key || undefined;\n}\n\n/**\n * True only for a genuinely multi-line InlineTable/InlineArray. Single-line\n * containers can never hold hoisted interior comments in the first place\n * (Non-goals in the plan doc), and — critically — `start.line === end.line`\n * for a single-line container means ANY same-line trailing comment on the\n * OUTER key-value (e.g. `data = [x, y] # note`) would otherwise appear to\n * fall \"inside\" a nested single-line array's own line range too, wrongly\n * treating an unrelated comment as hoisted from inside it. The element-level\n * ownership machinery below (resolveInlineElementSlots / removeMember's and\n * moveInlineElement's InlineTable/InlineArray branches) must only engage\n * here, matching writer.ts's own `isMultilineInlineContainer` convention.\n */\nfunction isMultilineInlineContainer(node: TreeNode): node is InlineTable | InlineArray {\n return (isInlineTable(node) || isInlineArray(node)) && node.loc.end.line > node.loc.start.line;\n}\n\nexport interface Slot {\n kind: 'member' | 'pinned';\n /** The orderable child: KeyValue | Table | TableArray. Absent for pinned runs. */\n member?: TreeNode;\n /** First key segment — `key.value[0]` / `key.item.value[0]`. Absent for pinned runs. */\n key?: string;\n /** Every node in the slot, in items-array order. */\n items: TreeNode[];\n /** min over items. */\n startLine: number;\n /** max over items — NOT the last item's end, because of hoisted comments. */\n endLine: number;\n}\n\nfunction getMemberKey(member: TreeNode): string | undefined {\n if (isKeyValue(member)) return member.key.value[0];\n if (isTable(member) || isTableArray(member)) return member.key.item.value[0];\n if (isInlineItem(member) && isKeyValue(member.item)) return (member.item as KeyValue).key.value[0];\n return undefined;\n}\n\n/**\n * The rule scan shared by resolveSlots (Document/Table/TableArray, where members\n * and comments are already interleaved in one items array) and\n * resolveInlineElementSlots (InlineTable/InlineArray, where they are merged from\n * two different arrays first — see that function). `items` must already be in\n * ascending line order; a `Comment` node is a comment, anything else is a member.\n */\nfunction scanSlots(\n items: TreeNode[],\n initialLastMemberEndLine: number,\n isEligibleForLeading: (member: TreeNode) => boolean,\n memberKey = getMemberKey\n): Slot[] {\n const slots: Slot[] = [];\n\n let lastMemberEndLine = initialLastMemberEndLine;\n let currentMemberSlot: Slot | undefined;\n let pendingRun: Comment[] = [];\n\n const flushPendingAsPinned = () => {\n if (!pendingRun.length) return;\n slots.push({\n kind: 'pinned',\n items: pendingRun,\n startLine: pendingRun[0].loc.start.line,\n endLine: last(pendingRun)!.loc.end.line\n });\n pendingRun = [];\n };\n\n for (const item of items) {\n if (isComment(item)) {\n if (item.loc.start.line <= lastMemberEndLine) {\n // R1: right-side ownership wins.\n if (currentMemberSlot) {\n currentMemberSlot.items.push(item);\n currentMemberSlot.endLine = Math.max(currentMemberSlot.endLine, item.loc.end.line);\n } else {\n // Owned by the container's own header (e.g. `[a] # hdr`), which\n // isn't itself a member of `items` — nothing to attach to, and it\n // never travels with any row.\n slots.push({ kind: 'pinned', items: [item], startLine: item.loc.start.line, endLine: item.loc.end.line });\n }\n continue;\n }\n\n const runEndLine = pendingRun.length ? last(pendingRun)!.loc.end.line : undefined;\n if (pendingRun.length && item.loc.start.line === runEndLine! + 1) {\n pendingRun.push(item);\n } else {\n flushPendingAsPinned();\n pendingRun.push(item);\n }\n continue;\n }\n\n // A member: KeyValue | Table | TableArray | InlineItem.\n let leading: Comment[] = [];\n if (pendingRun.length) {\n const runEndLine = last(pendingRun)!.loc.end.line;\n const adjacent = runEndLine + 1 === item.loc.start.line;\n if (adjacent && isEligibleForLeading(item)) {\n // R2, subject to R6. A commented-out KV whose key differs from\n // the following KV's key acts as a barrier: only comments after\n // the LAST such barrier belong to the KV. Dead entries whose\n // key matches the KV's key stay in the run (they are \"related\").\n // This applies to all-dead runs too — when every dead entry's\n // key matches the KV, R6 does not apply and the run is owned.\n const key = memberKey(item);\n if (key !== undefined) {\n let lastBarrierIdx = -1;\n for (let i = pendingRun.length - 1; i >= 0; i--) {\n // Use looksLikeKV for barrier detection — a line like\n // `# key = val # extra` still severs ownership even though\n // it isn't a \"pure\" dead entry.\n const ck = looksLikeKV(pendingRun[i]) ? commentedOutFirstKey(pendingRun[i]) : undefined;\n if (ck !== undefined && ck !== key) {\n lastBarrierIdx = i;\n break;\n }\n }\n if (lastBarrierIdx >= 0) {\n const pinned = pendingRun.splice(0, lastBarrierIdx + 1);\n slots.push({\n kind: 'pinned',\n items: pinned,\n startLine: pinned[0].loc.start.line,\n endLine: last(pinned)!.loc.end.line\n });\n }\n }\n leading = pendingRun;\n pendingRun = [];\n } else {\n // R3 (severed by a blank line) or R6 (dead-entry run) — pin it.\n flushPendingAsPinned();\n }\n }\n\n const slotItems: TreeNode[] = [...leading, item];\n const slot: Slot = {\n kind: 'member',\n member: item,\n key: memberKey(item),\n items: slotItems,\n startLine: slotItems[0].loc.start.line,\n endLine: item.loc.end.line\n };\n slots.push(slot);\n currentMemberSlot = slot;\n lastMemberEndLine = item.loc.end.line;\n }\n\n flushPendingAsPinned(); // R4: a trailing run with no member below it.\n\n return slots;\n}\n\n/**\n * Partitions a container's items into ownership slots, in document order.\n * Pure: does not mutate the tree.\n *\n * @param isEligibleForLeading - optional predicate; members that fail it cannot\n * acquire leading comments via R2. Used by callers that have just inserted\n * nodes which must not adopt a preceding run.\n */\nexport function resolveSlots(\n container: Document | Table | TableArray,\n isEligibleForLeading: (member: TreeNode) => boolean = () => true,\n memberKey: (member: TreeNode) => string | undefined = getMemberKey\n): Slot[] {\n // For a table body, comments on the header's own line (`[a] # hdr`) are\n // owned by the header itself (R1) — initialising to the header's end line\n // makes that fall out of the same check as ownership by a preceding row.\n const initialLastMemberEndLine = isDocument(container) ? 0 : container.key.loc.end.line;\n return scanSlots(container.items as TreeNode[], initialLastMemberEndLine, isEligibleForLeading, memberKey);\n}\n\n/**\n * The element-level analogue of resolveSlots, for a multi-line InlineTable or\n * InlineArray. Unlike Document/Table/TableArray, an inline container's own\n * `.items` can never hold a Comment (InlineTableItem/InlineArrayItem are both\n * InlineItem<...>) — the parser hoists interior comments out into the\n * *enclosing* Document/Table's `.items` instead (Background, case 4 in the\n * plan doc). `hostItems` is that enclosing container's `.items`; this merges\n * the comments physically inside `container`'s line range back in with\n * `container.items` (sorted into true reading order) before running the same\n * scan resolveSlots uses.\n *\n * There is no R6 analogue for bare array elements (they aren't `key = value`\n * shaped), but nothing here suppresses R6 for an InlineArray's own comments —\n * see docs/PLAN-Comment-Ownership.md for why that's an accepted, untested edge\n * case rather than a deliberate rule.\n */\nexport function resolveInlineElementSlots(\n container: InlineTable | InlineArray,\n hostItems: TreeNode[]\n): Slot[] {\n const interiorComments = hostItems.filter(\n (item): item is Comment =>\n isComment(item) &&\n (item.loc.start.line > container.loc.start.line ||\n (item.loc.start.line === container.loc.start.line && item.loc.start.column >= container.loc.start.column)) &&\n (item.loc.end.line < container.loc.end.line ||\n (item.loc.end.line === container.loc.end.line && item.loc.end.column <= container.loc.end.column))\n );\n\n const merged: TreeNode[] = [...(container.items as TreeNode[]), ...interiorComments].sort(\n (a, b) => a.loc.start.line - b.loc.start.line || a.loc.start.column - b.loc.start.column\n );\n\n return scanSlots(merged, container.loc.start.line, () => true);\n}\n\n/**\n * Finds the nearest Document/Table/TableArray ancestor whose OWN `.items`\n * holds the top-level Block from which `target` is reachable, following\n * KeyValue.value / InlineTable.items / InlineArray.items / InlineItem.item\n * links down through any nesting depth. This is where the parser files\n * comments hoisted out of `target` (Background, case 4) — regardless of how\n * deeply `target` is nested inside other inline containers, they always\n * flatten up to the same enclosing Document/Table.\n */\n/**\n * Finds the InlineItem that wraps `target` (an InlineTable/InlineArray)\n * inside its own parent container's items, searching the whole tree.\n */\nfunction findWrapperItem(root: TreeNode, target: TreeNode): InlineItem | undefined {\n function walk(node: TreeNode): InlineItem | undefined {\n if (isKeyValue(node)) return walk(node.value);\n if (!hasItems(node)) return undefined;\n for (const item of node.items as TreeNode[]) {\n if (isInlineItem(item) && item.item === target) return item;\n }\n for (const item of node.items as TreeNode[]) {\n const found = walk(isInlineItem(item) ? item.item : item);\n if (found) return found;\n }\n return undefined;\n }\n return walk(root);\n}\n\nexport function findHostContainer(root: Document, target: TreeNode): Document | Table | TableArray | undefined {\n function searchValue(value: TreeNode, container: Document | Table | TableArray): Document | Table | TableArray | undefined {\n if (value === target) return container;\n // An inline table's entries are InlineItems wrapping a KeyValue, so reaching anything\n // nested under one of its keys means stepping through that KeyValue's value. Without\n // this, `t = { xs = [...] }` never reaches `xs`'s array and the caller falls back to the\n // comment-oblivious path.\n if (isKeyValue(value)) return searchValue(value.value, container);\n if (isInlineTable(value) || isInlineArray(value)) {\n for (const inlineItem of (value as InlineTable | InlineArray).items) {\n if ((inlineItem as TreeNode) === target) return container;\n const found = searchValue(inlineItem.item, container);\n if (found) return found;\n }\n }\n return undefined;\n }\n\n function search(container: Document | Table | TableArray): Document | Table | TableArray | undefined {\n for (const item of container.items as TreeNode[]) {\n if (item === target) return container;\n if (isKeyValue(item)) {\n const found = searchValue(item.value, container);\n if (found) return found;\n } else if (isTable(item) || isTableArray(item)) {\n const found = search(item);\n if (found) return found;\n }\n }\n return undefined;\n }\n\n return search(root);\n}\n\n/**\n * R5, applied once as a general-purpose (non-destructive-to-text) pass: a\n * comment that visually introduces the next [table]/[[array]] block is\n * physically stored as a trailing item of the PREVIOUS block, because the\n * parser consumes everything up to the next `[` into the current table\n * (src/parse-toml.ts:517-524). This re-parents such runs into Document.items,\n * immediately before the block they visually belong to.\n *\n * Mutates the tree; loc-preserving, so serialized output is unchanged. NOTE:\n * because the re-parenting is loc-preserving, a document normalized this way\n * no longer matches what re-parsing its own serialized text would produce\n * (the parser always re-derives the original, pre-normalization container\n * assignment from the text). Do not call this as a blanket pre-pass before\n * general patching — it is intended for callers that immediately consume the\n * result without round-tripping through text (e.g. a future reorder pass that\n * is about to change those lines anyway). For deletion, `removeMember` below\n * computes the same R5 ownership lazily and only mutates when a comment is\n * genuinely being deleted, which has no such divergence risk.\n */\nexport function normalizeSectionComments(document: Document): void {\n for (let i = 0; i < document.items.length; i++) {\n const block = document.items[i];\n if (!isTable(block) && !isTableArray(block)) continue;\n\n const nextBlock = document.items[i + 1];\n if (!nextBlock) continue;\n\n const runItems = trailingOwnedRun(block, nextBlock);\n if (!runItems) continue;\n\n const items = block.items as TreeNode[];\n items.splice(items.length - runItems.length, runItems.length);\n document.items.splice(i + 1, 0, ...runItems);\n recalcContainerEnd(block);\n\n i += runItems.length; // skip over the just-inserted comments\n }\n}\n\n/**\n * R5, computed lazily: if `container`'s trailing comment run is R2-adjacent\n * to `nextBlock` (and not R6-dead), returns it — these are the comments a\n * removal of `nextBlock` must take along, even though they physically live\n * in `container.items`. Returns undefined otherwise.\n */\nfunction trailingOwnedRun(container: Table | TableArray, nextBlock: TreeNode): Comment[] | undefined {\n const lastSlot = last(resolveSlots(container));\n if (!lastSlot || lastSlot.kind !== 'pinned') return undefined;\n\n const runItems = lastSlot.items as Comment[];\n const adjacent = lastSlot.endLine + 1 === nextBlock.loc.start.line;\n const allDead = runItems.every(isCommentedOutEntry);\n if (!adjacent || allDead) return undefined;\n\n return runItems;\n}\n\n/**\n * Removes `member` from `parent.items` along with every comment it owns\n * (leading run and right-side/trailing comments — see resolveSlots), plus,\n * when `member` is a [table]/[[array]] block, any trailing comment run the\n * parser filed under the PRECEDING sibling table but which R5 assigns to\n * `member` instead. Falls back to a plain removal when `parent` isn't a\n * container the ownership model applies to (e.g. InlineTable/InlineArray).\n */\nexport function removeMember(root: Root, parent: TreeNode, member: TreeNode): void {\n if (isDocument(parent) && (isTable(member) || isTableArray(member))) {\n const index = (parent.items as TreeNode[]).indexOf(member);\n const previousSibling = index > 0 ? parent.items[index - 1] : undefined;\n if (previousSibling && (isTable(previousSibling) || isTableArray(previousSibling))) {\n const runItems = trailingOwnedRun(previousSibling, member);\n if (runItems) {\n for (const item of runItems) {\n remove(root, previousSibling, item);\n }\n }\n }\n }\n\n if (isDocument(parent) || isTable(parent) || isTableArray(parent)) {\n const slot = resolveSlots(parent).find(s => s.member === member);\n if (slot) {\n const memberIndex = slot.items.indexOf(member);\n\n // Leading comments and the member itself: every one of these occupies\n // its own line(s) that the member's own span does not otherwise cover,\n // so each is removed via the generic primitive, which computes real\n // line/column offset accounting.\n for (let i = 0; i <= memberIndex; i++) {\n const item = slot.items[i];\n // A prior remove() call in this loop may already have absorbed a\n // same-line trailing comment via its own single-comment logic —\n // see the trailing-comments loop below for why that's fine.\n if (!(parent.items as TreeNode[]).includes(item)) continue;\n remove(root, parent, item);\n }\n\n // Trailing (right-side, R1) comments: by definition their start line\n // is <= the member's own end line, so they sit *within* the span the\n // member's removal above already accounted for (a same-line trailing\n // comment, or one hoisted out of a multiline inline value). remove()'s\n // own legacy same-line check may already have absorbed a simple\n // trailing comment as a side effect of removing the member. Anything\n // still present here is spliced out directly, with NO further offset —\n // registering one would double-count a line height already removed.\n for (let i = memberIndex + 1; i < slot.items.length; i++) {\n const item = slot.items[i];\n const idx = (parent.items as TreeNode[]).indexOf(item);\n if (idx < 0) continue;\n (parent.items as TreeNode[]).splice(idx, 1);\n }\n return;\n }\n }\n\n if (isMultilineInlineContainer(parent) && isDocument(root)) {\n const hostContainer = findHostContainer(root, parent);\n if (hostContainer) {\n const slot = resolveInlineElementSlots(parent, hostContainer.items as TreeNode[]).find(s => s.member === member);\n if (slot) {\n const comments = slot.items.filter(item => item !== member) as Comment[];\n\n // Every comment in this slot is hoisted into hostContainer (the\n // enclosing Document/Table) — a DIFFERENT array from the member's own\n // `parent.items`, and NOT a sibling of it: hostContainer.items holds\n // the KeyValue that owns `parent` as its value, so an offset\n // registered there only ever affects that KeyValue's OWN siblings\n // (e.g. a later root key), never the surviving rows still inside\n // `parent` (a descendant of that KeyValue, not a sibling). Splicing\n // the comments out directly here (zero offset — purely structural),\n // then extending the member's own loc to cover their lines before\n // removing IT, lets remove()'s existing target-selection (a\n // preceding sibling row within `parent`, or an ENTER offset on\n // `parent` itself when the member is first) correctly propagate ONE\n // combined height reduction to both `parent`'s remaining rows and\n // whatever comes after it — it only needs the full height, comments\n // included, in a single call. `member` is being discarded regardless,\n // so mutating its own loc here has no lasting effect.\n for (const comment of comments) {\n const idx = (hostContainer.items as TreeNode[]).indexOf(comment);\n if (idx < 0) continue;\n (hostContainer.items as TreeNode[]).splice(idx, 1);\n }\n\n if (comments.length) {\n member.loc.start = slot.items[0].loc.start;\n member.loc.end = last(slot.items)!.loc.end;\n }\n\n remove(root, parent, member, hostContainer.items as TreeNode[]);\n\n // Flush immediately, matching moveInlineElement's identical discipline (see\n // its docstring): writer.remove()'s own orphaned-comment compensation above\n // mutates surviving comments' `.loc` as a PRE-compensation for an offset that\n // only actually resolves once applyWrites runs. If a SECOND removeMember (or\n // moveInlineElement) call on this same container ran before that offset were\n // resolved, resolveInlineElementSlots would read those pre-compensated,\n // not-yet-restored positions as if they were final — misattributing or\n // losing ownership. Flushing here keeps every subsequent call in this patch\n // starting from a fully-resolved, non-stale state.\n applyWrites(root);\n return;\n }\n }\n }\n\n remove(root, parent, member);\n}\n\n/**\n * Relocates `node` (an element of `parent`, an InlineTable/InlineArray) from\n * its current position to `toIndex`, carrying its own owned comments along\n * (see resolveInlineElementSlots) rather than leaving them at their old\n * absolute position — which is what plain remove()+insert() does, and why a\n * Move on a commented inline array can misplace a comment onto an unrelated\n * line (see \"Extending to elements inside multi-line arrays\" in\n * docs/PLAN-Comment-Ownership.md).\n *\n * It isn't enough to protect only `node`'s own comments: writer.remove()'s\n * per-container \"orphaned comment\" cleanup reasons purely by absolute line\n * number, with no notion of ownership, so relocating `node` past *other*\n * elements can drag an unrelated element's own comment along as a side\n * effect (or leave it stranded) even though that element never moved. Every\n * commented element in the container is protected the same way: its\n * comment(s) are detached before the move and re-attached afterward, based\n * on how far *that specific element* actually shifted — which may differ\n * from how far `node` itself moved, or be zero.\n */\nexport function moveInlineElement(root: Root, parent: TreeNode, node: TreeNode, toIndex: number): void {\n let sharedLineContainerBeforeMove = false;\n if (isMultilineInlineContainer(parent) && isDocument(root)) {\n const hostContainer = findHostContainer(root, parent);\n if (hostContainer) {\n const slots = resolveInlineElementSlots(parent, hostContainer.items as TreeNode[]);\n\n // The container's per-line vs shared-line layout must be judged on\n // the state BEFORE this move: remove()+insert() inflate the tail's\n // line coordinates, and a later perLine() read of the corrupted span\n // misclassifies a shared-line container as per-line, skipping the\n // tail realignment and stranding the rows (fuzz seed 16034).\n //\n // The honest signature of a shared-line layout is a RUN of at least\n // three adjacent items STARTING on the same line. Two items sharing\n // a line is the signature of a per-line container whose multiline\n // member ends on the next item's line — the writer offsets handle\n // those (fuzz seeds 9553, 9829). A same-line pair caused by a\n // just-inserted item still carrying its pending exit offset is\n // transient and must not count (fuzz seed 761).\n {\n const items = (parent as InlineTable | InlineArray).items as TreeNode[];\n let run = 1;\n for (let i = 1; i < items.length; i++) {\n if (items[i].loc.start.line === items[i - 1].loc.start.line) {\n const prevPending = getExitOffsets(root).get(items[i - 1]);\n const selfPending = getExitOffsets(root).get(items[i]);\n if (prevPending || selfPending) continue;\n run++;\n if (run >= 3) {\n sharedLineContainerBeforeMove = true;\n break;\n }\n } else {\n run = 1;\n }\n }\n }\n\n const detached: Array<{ owner: TreeNode; ownerOriginalStart: { line: number; column: number }; comments: Comment[] }> = [];\n let nodeOwnStart: { line: number; column: number } | undefined;\n let nodeOwnEnd: { line: number; column: number } | undefined;\n let nodeInnerEnd: { line: number; column: number } | undefined;\n\n // Snapshot descendants of the moved node that start BELOW its first\n // line. insert()'s rigid horizontal translation shifts every subtree\n // column by the first line's column delta, but interior rows of a\n // multiline inline table/array are indented from line start (not from\n // the opening bracket), so they must not move sideways. This covers\n // both rows anchored to a preceding multiline value's end column\n // (fuzz seed 706: `, 5, 6` after a multiline string inside a moved\n // nested array slid left onto the string's closing quotes) and the\n // FIRST row of a multiline container that has no predecessor at all\n // (fuzz seed 599513: `nxweV7FF3` slid to a negative column and toTOML\n // emitted `,-1.5nx=`).\n const anchoredDescendants: Array<{ node: TreeNode; start: { line: number; column: number }; end: { line: number; column: number }; endOnly?: boolean; equals?: number }> = [];\n const collectAnchored = (container: TreeNode, firstLine: number) => {\n if (!hasItems(container)) return;\n const items = container.items as TreeNode[];\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const below = item.loc.start.line > firstLine;\n if (below) {\n anchoredDescendants.push({ node: item, start: clonePosition(item.loc.start), end: clonePosition(item.loc.end) });\n }\n // A multiline element's wrapper END (where its comma lands) is\n // anchored to the element's own end column, which the leaf path of\n // the rigid translation leaves alone — but the wrapper's end is\n // shifted with the first line. Restore it too.\n if (item.loc.end.line > firstLine && item.loc.end.line > item.loc.start.line) {\n anchoredDescendants.push({ node: item, start: clonePosition(item.loc.start), end: clonePosition(item.loc.end), endOnly: true });\n }\n if (isInlineItem(item)) {\n const inner = item.item;\n if (below) {\n const kv = isKeyValue(inner) ? inner : undefined;\n anchoredDescendants.push({\n node: inner,\n start: clonePosition(inner.loc.start),\n end: clonePosition(inner.loc.end),\n equals: kv ? kv.equals : undefined\n });\n // The KV's key and value nodes ride the same rigid translation\n // as the row, but only the row and the KV are restored above —\n // the key keeps its shifted column and toTOML writes it at its\n // own loc, overwriting the preceding content (fuzz seed 19506).\n if (kv) {\n anchoredDescendants.push({\n node: kv.key,\n start: clonePosition(kv.key.loc.start),\n end: clonePosition(kv.key.loc.end)\n });\n anchoredDescendants.push({\n node: kv.value,\n start: clonePosition(kv.value.loc.start),\n end: clonePosition(kv.value.loc.end)\n });\n }\n }\n // A multiline STRING's own end column is what its closing quotes\n // follow — offsets can nudge it while the wrapper's end (with the\n // comma) stays put, making toTOML's multiline writer consume the\n // columns between them (fuzz seed 706). Restore it independently.\n if (inner.loc.end.line > firstLine && inner.loc.end.line > inner.loc.start.line) {\n anchoredDescendants.push({ node: inner, start: clonePosition(inner.loc.start), end: clonePosition(inner.loc.end), endOnly: true });\n }\n collectAnchored(inner, firstLine);\n } else if (hasItems(item)) {\n collectAnchored(item, firstLine);\n }\n }\n };\n\n for (const slot of slots) {\n if (slot.kind !== 'member' || !slot.member) continue;\n const comments = slot.items.filter(item => item !== slot.member) as Comment[];\n\n if (slot.member === node) {\n nodeOwnStart = clonePosition(node.loc.start);\n nodeOwnEnd = clonePosition(node.loc.end);\n if (isInlineItem(node)) {\n nodeInnerEnd = clonePosition(node.item.loc.end);\n }\n collectAnchored(isInlineItem(node) ? node.item : node, nodeOwnStart.line);\n if (comments.length) {\n // Extend node's own loc to the full group span so the bare\n // remove()+insert() below accounts for the combined height —\n // matters for a leading, separate-line comment; a no-op for a\n // same-line trailing one, since that doesn't change the line\n // count (mirrors removeMember's identical trick).\n node.loc.start = clonePosition(slot.items[0].loc.start);\n node.loc.end = clonePosition(last(slot.items)!.loc.end);\n }\n }\n\n if (!comments.length) continue;\n detached.push({ owner: slot.member, ownerOriginalStart: clonePosition(slot.member.loc.start), comments });\n for (const comment of comments) {\n const idx = (hostContainer.items as TreeNode[]).indexOf(comment);\n if (idx >= 0) (hostContainer.items as TreeNode[]).splice(idx, 1);\n }\n }\n\n // For a multiline item removed from the END of a shared-line container,\n // remove()'s bracket-slide offset (fuzz seed 706) mixes the removed\n // item's LAST line with the previous item's line. The re-insert below\n // cannot cancel it — its own span-based offset has the same cross-line\n // defect — so the pair leaks past the container and corrupts every\n // subsequent node on the flush (fuzz seed 900: the rows after the array\n // slid onto the multiline string's content). Drop both; the tail\n // realignment below repositions the container's interior explicitly.\n const nodeIndexBeforeRemove = (parent.items as TreeNode[]).indexOf(node);\n const removedWasLast = nodeIndexBeforeRemove === (parent.items as TreeNode[]).length - 1;\n const prevBeforeRemove = nodeIndexBeforeRemove > 0\n ? (parent.items as TreeNode[])[nodeIndexBeforeRemove - 1]\n : undefined;\n\n // A multiline node moved to the FRONT (index 0) that, before the move,\n // shared its START line with the item now following it (`prevBeforeRemove`,\n // which ends up at index 1). The writer's per-line offset model assumes\n // each item sits on its own line, so the shared-line item's columns go\n // stale (it lands with a negative start column, overwriting the moved\n // multiline string's closing delimiter). The tail realignment below is\n // gated on `sharedLineContainerBeforeMove`, which a two-item same-line\n // pairing does NOT satisfy — so record this case explicitly (fuzz seed\n // 421965: `[false, \"\"\"\\nAAA\\n\"\"\", \"z\"]` moving the string to the front\n // left `false` at column -2 on the string's last line).\n const movedMultilineToFront = toIndex === 0 && nodeIndexBeforeRemove > 0 &&\n node.loc.end.line > node.loc.start.line &&\n prevBeforeRemove !== undefined &&\n prevBeforeRemove.loc.start.line === node.loc.start.line;\n\n remove(root, parent, node, hostContainer.items as TreeNode[]);\n\n let cancelMultilineLastRemovalOffsets = false;\n if (removedWasLast && prevBeforeRemove !== undefined &&\n node.loc.end.line > node.loc.start.line &&\n !perLine(parent as InlineArray | InlineTable)) {\n const prevPending = getExitOffsets(root).get(prevBeforeRemove);\n if (prevPending) {\n getExitOffsets(root).delete(prevBeforeRemove);\n cancelMultilineLastRemovalOffsets = true;\n }\n }\n\n // Resolve the removal's offsets before re-inserting, so insert()\n // measures against final positions. Otherwise insert() absorbs the\n // removal's pending exit offset into the inserted item's own offset,\n // which then leaks into the container's end column (and any wrapper\n // InlineItem's end) — a comma or closing bracket lands inside the\n // last value on that line (fuzz seed 50).\n applyWrites(root);\n insert(root, parent, node, toIndex, undefined, hostContainer.items as TreeNode[]);\n\n if (cancelMultilineLastRemovalOffsets) {\n const childPending = getExitOffsets(root).get(node);\n if (childPending) {\n childPending.lines = 0;\n childPending.columns = 0;\n }\n }\n\n // Flush before reading anything back out below. Every other element's\n // own loc (an untouched sibling that nonetheless shifted because this\n // move made room around it) only becomes fully current at this point,\n // and it's what each owner's delta below is computed against. It also\n // means any FURTHER change in this patch touching the same container\n // starts from a fully-resolved, non-stale state.\n applyWrites(root);\n\n // insert() translates the node rigidly: every line of a multi-line\n // node receives the first line's column delta. A multi-line value's\n // content columns below the first line are part of its raw text and\n // must not move — the writer only reads the END column on the last\n // line, so restore just that, on both the wrapper InlineItem and the\n // inner value node it wraps (fuzz seed 50).\n if (nodeOwnStart && nodeOwnEnd && node.loc.end.line > node.loc.start.line) {\n node.loc.end.column = nodeOwnEnd.column;\n // The inner value keeps its OWN original end — for a multiline\n // string the wrapper's end includes the comma that follows, and\n // assigning it to the string makes toTOML's multiline writer\n // consume the columns between the closing quotes and the next item\n // (fuzz seed 706).\n if (isInlineItem(node) && nodeInnerEnd && node.item.loc.end.line > node.item.loc.start.line) {\n node.item.loc.end.column = nodeInnerEnd.column;\n }\n }\n\n // Restore the columns of anchored below-first-line descendants that the\n // rigid translation shifted horizontally (see the snapshot comment above).\n for (const { node: descendant, start, end, endOnly, equals } of anchoredDescendants) {\n if (endOnly) {\n descendant.loc.end.column = end.column;\n continue;\n }\n descendant.loc.start.column = start.column;\n if (descendant.loc.end.line === descendant.loc.start.line) {\n descendant.loc.end.column = end.column;\n }\n if (equals !== undefined && isKeyValue(descendant)) {\n (descendant as KeyValue).equals = equals;\n }\n }\n\n for (const { owner, ownerOriginalStart, comments } of detached) {\n let delta: { lines: number; columns: number };\n if (owner === node) {\n // node.loc is still the (possibly extended) relocated group span;\n // derive the shift from that, then restore node's own bare span.\n delta = {\n lines: node.loc.start.line - ownerOriginalStart.line,\n columns: node.loc.start.column - ownerOriginalStart.column\n };\n node.loc.start = { line: nodeOwnStart!.line + delta.lines, column: nodeOwnStart!.column + delta.columns };\n node.loc.end = { line: nodeOwnEnd!.line + delta.lines, column: nodeOwnEnd!.column + delta.columns };\n } else {\n delta = {\n lines: owner.loc.start.line - ownerOriginalStart.line,\n columns: owner.loc.start.column - ownerOriginalStart.column\n };\n }\n\n for (const comment of comments) {\n shiftNode(comment, delta);\n const insertAt = (hostContainer.items as TreeNode[]).findIndex(\n item => item.loc.start.line > comment.loc.start.line\n );\n if (insertAt === -1) (hostContainer.items as TreeNode[]).push(comment);\n else (hostContainer.items as TreeNode[]).splice(insertAt, 0, comment);\n }\n }\n\n // The writer's offset model assumes the next sibling sits at the moved\n // node's first-line column. When the moved node wraps lines (a\n // multiline string) inside a container whose items share lines, that\n // assumption breaks and every item after the moved one lands in the\n // wrong place, dragging the container's (and any wrapper InlineItem's)\n // end column with it. Realign the tail sequentially: each item starts\n // right after the previous one's end (fuzz seed 50).\n const container = parent as InlineTable | InlineArray;\n // Gate the tail realignment on the original layout classification:\n // perLine() reads the container's own end, which the moves above can\n // leave stale. The pre-move capture reflects the true layout. A\n // multiline node moved to the front also needs the tail realignment\n // (see movedMultilineToFront above), even though the shared-line run\n // is only two items and `sharedLineContainerBeforeMove` stays false.\n const sharedLineContainer = sharedLineContainerBeforeMove || movedMultilineToFront;\n if (sharedLineContainer) {\n // Re-anchor the interior rows of a multiline inline container whose\n // subtree the tail shift above translated rigidly: the shiftNode\n // moves every row's START, but rows anchored to a preceding\n // multiline value keep their END columns — the boundary between a\n // multiline string row and the next row then closes up and the\n // separator comma is overwritten (fuzz seed 16552).\n const realignInterior = (inner: InlineTable | InlineArray, wrapper?: TreeNode) => {\n let anchor: { line: number; column: number } | undefined;\n for (const row of inner.items as TreeNode[]) {\n if (!anchor) {\n anchor = { line: row.loc.end.line, column: row.loc.end.column + 2 };\n continue;\n }\n const d = {\n lines: anchor.line - row.loc.start.line,\n columns: anchor.column - row.loc.start.column\n };\n if (d.lines !== 0 || d.columns !== 0) {\n shiftNode(row, d);\n if (row.loc.end.line > row.loc.start.line) {\n row.loc.end.column -= d.columns;\n if (isInlineItem(row) && row.item.loc.end.line > row.item.loc.start.line) {\n row.item.loc.end.column -= d.columns;\n }\n }\n const rowInner = isInlineItem(row)\n ? (isKeyValue(row.item) ? row.item.value : row.item)\n : row;\n if ((isInlineTable(rowInner) || isInlineArray(rowInner)) &&\n rowInner.loc.end.line > rowInner.loc.start.line) {\n realignInterior(rowInner, row);\n }\n }\n anchor = { line: row.loc.end.line, column: row.loc.end.column + 2 };\n }\n if (anchor) {\n inner.loc.end = { line: anchor.line, column: anchor.column - 1 };\n // The enclosing InlineItem's end carries the comma that follows\n // the closing brace — track the new end so the comma stays\n // adjacent (fuzz seed 16552).\n if (wrapper && wrapper.loc.end.line === inner.loc.end.line) {\n wrapper.loc.end.column = inner.loc.end.column;\n }\n }\n };\n\n let tailAnchor: { line: number; column: number } | undefined;\n for (const item of container.items as TreeNode[]) {\n if (item === node) {\n tailAnchor = { line: node.loc.end.line, column: node.loc.end.column + 2 };\n continue;\n }\n if (!tailAnchor) continue;\n const delta = {\n lines: tailAnchor.line - item.loc.start.line,\n columns: tailAnchor.column - item.loc.start.column\n };\n if (delta.lines !== 0 || delta.columns !== 0) {\n shiftNode(item, delta);\n const itemInner = isInlineItem(item)\n ? (isKeyValue(item.item) ? item.item.value : item.item)\n : item;\n if ((isInlineTable(itemInner) || isInlineArray(itemInner)) &&\n itemInner.loc.end.line > itemInner.loc.start.line) {\n realignInterior(itemInner, isInlineItem(item) ? item : undefined);\n }\n }\n // A multiline STRING member's end line may be stale (the move\n // offsets inflated it) — derive it from the raw content so the\n // chain doesn't push the following items onto the wrong lines\n // (fuzz seed 9553).\n let itemEndLine = item.loc.end.line;\n const tailInner = isInlineItem(item) ? item.item : item;\n if (isString(tailInner) && tailInner.loc.end.line > tailInner.loc.start.line) {\n itemEndLine = tailInner.loc.start.line + tailInner.raw.split('\\n').length - 1;\n tailInner.loc.end.line = itemEndLine;\n item.loc.end.line = itemEndLine;\n }\n tailAnchor = { line: itemEndLine, column: item.loc.end.column + 2 };\n }\n if (tailAnchor) {\n const endBeforeRealign = clonePosition(container.loc.end);\n container.loc.end = { line: tailAnchor.line, column: tailAnchor.column - 1 };\n\n // The container may itself be an element of another inline\n // container; the wrapper InlineItem's end must track the\n // container's end or its comma lands inside the last value.\n const wrapper = findWrapperItem(root, container as TreeNode);\n if (wrapper) {\n wrapper.loc.end = { line: container.loc.end.line, column: container.loc.end.column };\n }\n\n // Nodes AFTER the container (same-line followers, enclosing\n // table rows, the table's own end) were positioned by the writer\n // offsets this realignment has just replaced. Re-anchor them to\n // the new end with a pending exit offset so a later flush shifts\n // them by exactly the end delta (fuzz seed 900: the row following\n // the moved array would otherwise sit on the moved item's stale\n // column and the subsequent removal then slides it sideways onto\n // the multiline string's content).\n const endDelta = {\n lines: container.loc.end.line - endBeforeRealign.line,\n columns: container.loc.end.column - endBeforeRealign.column\n };\n if (endDelta.lines !== 0 || endDelta.columns !== 0) {\n addExitOffset(root, wrapper ?? (container as TreeNode), endDelta);\n }\n }\n }\n\n return;\n }\n }\n\n // Capture the container's bracket gaps before the move so they can be\n // restored afterwards. remove()+insert() uses writer offsets that do\n // not perfectly cancel over consecutive Moves on the same container,\n // which corrupts the leading gap (space after `[`/`{`) and trailing gap\n // (space before `]`/`}`).\n const container = parent as InlineTable | InlineArray;\n const itemsBefore = container.items as TreeNode[];\n const firstBefore = itemsBefore[0];\n const lastBefore = itemsBefore[itemsBefore.length - 1];\n const originalLeadingGap = firstBefore.loc.start.column - container.loc.start.column - 1;\n const originalTrailingGap = container.loc.end.column - 1 - lastBefore.loc.end.column;\n\n remove(root, parent, node);\n insert(root, parent, node, toIndex);\n\n // Flush so consecutive Moves start from resolved positions (prevents\n // exit-offset accumulation on the same target) and so the gap\n // measurements below see final positions.\n applyWrites(root);\n\n // Restore bracket gaps corrupted by the move's offsets.\n const itemsAfter = container.items as TreeNode[];\n const firstAfter = itemsAfter[0];\n const leadingGap = firstAfter.loc.start.column - container.loc.start.column - 1;\n if (leadingGap !== originalLeadingGap) {\n shiftNode(firstAfter, {\n lines: 0,\n columns: originalLeadingGap - leadingGap\n });\n }\n const lastAfter = itemsAfter[itemsAfter.length - 1];\n const trailingGap = container.loc.end.column - 1 - lastAfter.loc.end.column;\n if (trailingGap !== originalTrailingGap) {\n container.loc.end.column = lastAfter.loc.end.column + 1 + originalTrailingGap;\n }\n}\n"],"mappings":";;;;;;;AA6BA,MAAM,cAAc,OAAO,GAAG;;AAG9B,MAAa,6BACX,IAAI,OAAO,OAAO,GAAG,QAAQ,YAAY,aAAa,YAAY,OAAO;;;;;AAM3E,MAAM,cAAc,OAAO,GAAG;;AAG9B,MAAM,2BACJ,IAAI,OAAO,OAAO,GAAG,QAAQ,YAAY,aAAa,YAAY,WAAW,YAAY,KAAK;;AAGhG,MAAa,0BACX,IAAI,OAAO,OAAO,GAAG,gBAAgB,YAAY,aAAa,YAAY,eAAe;AAE3F,SAAgB,oBAAoB,SAA2B;CAC7D,OAAO,yBAAyB,KAAK,QAAQ,GAAG,KAAK,wBAAwB,KAAK,QAAQ,GAAG;AAC/F;;;;;;;AAQA,SAAS,2BAA2B,SAA2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CAChC,MAAM,aAAa,YAAY,YAAY,SAAS;CACpD,MAAM,qBAAqB,YAAY,IAAI,MAAM,SAAS,UAAU,IAAI,MAAM,SAAS;CACvF,MAAM,sBAAsB,UAAU,IAAI,IAAI,SAAS,IAAI,WAAW,IAAI,IAAI;CAE9E,OAAO,MAAM,QAAQ,IAAI;CACzB,OAAO,MAAM,QAAQ,MAAM,OAAO;CAKlC,YAAY,IAAI;CAGhB,MAAM,aAAa,UAAU;CAC7B,MAAM,aAAa,WAAW;CAC9B,MAAM,aAAa,WAAW,IAAI,MAAM,SAAS,UAAU,IAAI,MAAM,SAAS;CAC9E,IAAI,eAAe,oBACjB,UAAU,YAAY;EACpB,OAAO;EACP,SAAS,qBAAqB;CAChC,CAAC;CAEH,MAAM,YAAY,WAAW,WAAW,SAAS;CAEjD,IADoB,UAAU,IAAI,IAAI,SAAS,IAAI,UAAU,IAAI,IAAI,WACjD,qBAClB,UAAU,IAAI,IAAI,SAAS,UAAU,IAAI,IAAI,SAAS,IAAI;AAE9D"}
|
|
1
|
+
{"version":3,"file":"comment-ownership.js","names":[],"sources":["../../src/comment-ownership.ts"],"sourcesContent":["import {\n Document,\n Table,\n TableArray,\n InlineTable,\n InlineArray,\n KeyValue,\n TreeNode,\n Comment,\n isComment,\n isKeyValue,\n isTable,\n isTableArray,\n isDocument,\n isInlineTable,\n isInlineArray,\n isInlineItem,\n isString,\n hasItems,\n InlineItem\n} from './cst';\nimport { last } from './utils';\nimport { clonePosition } from './location';\nimport { remove, insert, shiftNode, applyWrites, recalcContainerEnd, perLine, getExitOffsets, addExitOffset, Root } from './writer';\n\n// See docs/Comment-Ownership.md for the full model (rules R1-R6).\n\n// R6 — commented-out entries are not owned.\n// Segment charset matches IS_BARE_KEY (/^[\\w-]+$/, src/tokenizer.ts:22).\nconst KEY_SEGMENT = String.raw`(?:[\\w-]+|\"[^\"]*\"|'[^']*')`;\n\n/** `# key = ...`, `# a.b.c = ...`, `# \"quoted key\" = ...` */\nexport const IS_COMMENTED_OUT_KEY_VALUE =\n new RegExp(String.raw`^#\\s*${KEY_SEGMENT}(?:\\s*\\.\\s*${KEY_SEGMENT})*\\s*=`);\n\n/** A value after `=` in a commented-out KV: a quoted string, number, boolean,\n * date-like token, or a single bare word. Multi-word prose (e.g.\n * `# key = 1 is something to consider`) does NOT match, so the comment\n * is treated as alive prose rather than a dead entry. */\nconst VALUE_TOKEN = String.raw`(?:\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*'|\"\"\"[\\s\\S]*?\"\"\"|'''[\\s\\S]*?'''|[^\\s#]+)`;\n\n/** Full-line match: `# key = value` where value is a single token. */\nconst IS_PURE_COMMENTED_OUT_KV =\n new RegExp(String.raw`^#\\s*${KEY_SEGMENT}(?:\\s*\\.\\s*${KEY_SEGMENT})*\\s*=\\s*${VALUE_TOKEN}\\s*$`);\n\n/** `# [table]`, `# [[array]]`, `# [a.b]` */\nexport const IS_COMMENTED_OUT_HEADER =\n new RegExp(String.raw`^#\\s*\\[\\[?\\s*${KEY_SEGMENT}(?:\\s*\\.\\s*${KEY_SEGMENT})*\\s*\\]\\]?\\s*$`);\n\nexport function isCommentedOutEntry(comment: Comment): boolean {\n return IS_PURE_COMMENTED_OUT_KV.test(comment.raw) || IS_COMMENTED_OUT_HEADER.test(comment.raw);\n}\n\n/**\n * True when a `#` appears outside of quotes after the `=` in a\n * commented-out-KV line — i.e. the line has an inline trailing comment\n * (`# key = val # note`). `#` inside a quoted value (e.g.\n * `# key = \"a # b\" extra`) is NOT an inline comment.\n */\nfunction hasInlineCommentAfterValue(comment: Comment): boolean {\n const eqIdx = comment.raw.indexOf('=');\n if (eqIdx < 0) return false;\n let inDQuote = false;\n let inSQuote = false;\n for (let i = eqIdx + 1; i < comment.raw.length; i++) {\n const ch = comment.raw[i];\n if (ch === '\\\\') { i++; continue; }\n if (!inSQuote && ch === '\"') { inDQuote = !inDQuote; continue; }\n if (!inDQuote && ch === \"'\") { inSQuote = !inSQuote; continue; }\n if (!inDQuote && !inSQuote && ch === '#') return true;\n }\n return false;\n}\n\n/**\n * True when the comment looks enough like a KV to act as a barrier in\n * scanGroups. Broader than `isCommentedOutEntry`: also matches lines with\n * an inline trailing comment (`# key = val # note`) and lines whose value\n * part is short enough not to be obvious prose (≤3 words after `=`).\n */\nfunction looksLikeKV(comment: Comment): boolean {\n if (isCommentedOutEntry(comment)) return true;\n if (!IS_COMMENTED_OUT_KEY_VALUE.test(comment.raw)) return false;\n // Has an inline comment after the value: `# key = val # note`\n if (hasInlineCommentAfterValue(comment)) return true;\n // Short value: `# key = a few words` (not running prose)\n const afterEq = comment.raw.replace(/^[^=]*=\\s*/, '');\n const wordCount = afterEq.split(/\\s+/).filter(Boolean).length;\n return wordCount <= 3;\n}\n\n/** Extract the first key segment from a commented-out KV like `# key = val`. */\nfunction commentedOutFirstKey(comment: Comment): string | undefined {\n const m = comment.raw.match(IS_COMMENTED_OUT_KEY_VALUE);\n if (!m) return undefined;\n // Strip `#` prefix and everything from `=` onward, then trim.\n // For dotted keys like `# a.b.c = val`, this gives `a.b.c`.\n let key = m[0].replace(/^#\\s*/, '').replace(/\\s*=.*$/, '').trim();\n // Take only the first segment for comparison with the KV's own first key.\n const dot = key.indexOf('.');\n if (dot >= 0) key = key.substring(0, dot);\n // Strip quotes if present\n if ((key.startsWith('\"') && key.endsWith('\"')) || (key.startsWith(\"'\") && key.endsWith(\"'\"))) {\n key = key.slice(1, -1);\n }\n return key || undefined;\n}\n\n/**\n * True only for a genuinely multi-line InlineTable/InlineArray. Single-line\n * containers can never hold hoisted interior comments in the first place\n * (Non-goals in the plan doc), and — critically — `start.line === end.line`\n * for a single-line container means ANY same-line trailing comment on the\n * OUTER key-value (e.g. `data = [x, y] # note`) would otherwise appear to\n * fall \"inside\" a nested single-line array's own line range too, wrongly\n * treating an unrelated comment as hoisted from inside it. The element-level\n * ownership machinery below (resolveInlineElementGroups / removeMember's and\n * moveInlineElement's InlineTable/InlineArray branches) must only engage\n * here, matching writer.ts's own `isMultilineInlineContainer` convention.\n */\nfunction isMultilineInlineContainer(node: TreeNode): node is InlineTable | InlineArray {\n return (isInlineTable(node) || isInlineArray(node)) && node.loc.end.line > node.loc.start.line;\n}\n\nexport interface Group {\n kind: 'member' | 'pinned';\n /** The orderable child: KeyValue | Table | TableArray. Absent for pinned blocks. */\n member?: TreeNode;\n /** First key segment — `key.value[0]` / `key.item.value[0]`. Absent for pinned blocks. */\n key?: string;\n /** Every node in the group, in items-array order. */\n items: TreeNode[];\n /** min over items. */\n startLine: number;\n /** max over items — NOT the last item's end, because of hoisted comments. */\n endLine: number;\n}\n\nfunction getMemberKey(member: TreeNode): string | undefined {\n if (isKeyValue(member)) return member.key.value[0];\n if (isTable(member) || isTableArray(member)) return member.key.item.value[0];\n if (isInlineItem(member) && isKeyValue(member.item)) return (member.item as KeyValue).key.value[0];\n return undefined;\n}\n\n/**\n * The rule scan shared by resolveGroups (Document/Table/TableArray, where members\n * and comments are already interleaved in one items array) and\n * resolveInlineElementGroups (InlineTable/InlineArray, where they are merged from\n * two different arrays first — see that function). `items` must already be in\n * ascending line order; a `Comment` node is a comment, anything else is a member.\n */\nfunction scanGroups(\n items: TreeNode[],\n initialLastMemberEndLine: number,\n isEligibleForLeading: (member: TreeNode) => boolean,\n memberKey = getMemberKey\n): Group[] {\n const groups: Group[] = [];\n\n let lastMemberEndLine = initialLastMemberEndLine;\n let currentMemberGroup: Group | undefined;\n let pendingRun: Comment[] = [];\n\n const flushPendingAsPinned = () => {\n if (!pendingRun.length) return;\n groups.push({\n kind: 'pinned',\n items: pendingRun,\n startLine: pendingRun[0].loc.start.line,\n endLine: last(pendingRun)!.loc.end.line\n });\n pendingRun = [];\n };\n\n for (const item of items) {\n if (isComment(item)) {\n if (item.loc.start.line <= lastMemberEndLine) {\n // R1: trailing ownership.\n if (currentMemberGroup) {\n currentMemberGroup.items.push(item);\n currentMemberGroup.endLine = Math.max(currentMemberGroup.endLine, item.loc.end.line);\n } else {\n // Owned by the container's own header (e.g. `[a] # hdr`), which\n // isn't itself a member of `items` — nothing to attach to, and it\n // never travels with any row.\n groups.push({ kind: 'pinned', items: [item], startLine: item.loc.start.line, endLine: item.loc.end.line });\n }\n continue;\n }\n\n const runEndLine = pendingRun.length ? last(pendingRun)!.loc.end.line : undefined;\n if (pendingRun.length && item.loc.start.line === runEndLine! + 1) {\n pendingRun.push(item);\n } else {\n flushPendingAsPinned();\n pendingRun.push(item);\n }\n continue;\n }\n\n // A member: KeyValue | Table | TableArray | InlineItem.\n let leading: Comment[] = [];\n if (pendingRun.length) {\n const runEndLine = last(pendingRun)!.loc.end.line;\n const adjacent = runEndLine + 1 === item.loc.start.line;\n if (adjacent && isEligibleForLeading(item)) {\n // R2, subject to R6. A commented-out KV whose key differs from\n // the following KV's key acts as a barrier: only comments after\n // the LAST such barrier belong to the KV. Dead entries whose\n // key matches the KV's key stay in the block (they are \"related\").\n // This applies to all-dead blocks too — when every dead entry's\n // key matches the KV, R6 does not apply and the block is owned.\n const key = memberKey(item);\n if (key !== undefined) {\n let lastBarrierIdx = -1;\n for (let i = pendingRun.length - 1; i >= 0; i--) {\n // Use looksLikeKV for barrier detection — a line like\n // `# key = val # extra` still severs ownership even though\n // it isn't a \"pure\" dead entry.\n const ck = looksLikeKV(pendingRun[i]) ? commentedOutFirstKey(pendingRun[i]) : undefined;\n if (ck !== undefined && ck !== key) {\n lastBarrierIdx = i;\n break;\n }\n }\n if (lastBarrierIdx >= 0) {\n const pinned = pendingRun.splice(0, lastBarrierIdx + 1);\n groups.push({\n kind: 'pinned',\n items: pinned,\n startLine: pinned[0].loc.start.line,\n endLine: last(pinned)!.loc.end.line\n });\n }\n }\n leading = pendingRun;\n pendingRun = [];\n } else {\n // R3 (severed by a blank line) or R6 (dead-entry block) — pin it.\n flushPendingAsPinned();\n }\n }\n\n const groupItems: TreeNode[] = [...leading, item];\n const group: Group = {\n kind: 'member',\n member: item,\n key: memberKey(item),\n items: groupItems,\n startLine: groupItems[0].loc.start.line,\n endLine: item.loc.end.line\n };\n groups.push(group);\n currentMemberGroup = group;\n lastMemberEndLine = item.loc.end.line;\n }\n\n flushPendingAsPinned(); // R4: a trailing block with no member below it.\n\n return groups;\n}\n\n/**\n * Partitions a container's items into ownership groups, in document order.\n * Pure: does not mutate the tree.\n *\n * @param isEligibleForLeading - optional predicate; members that fail it cannot\n * acquire leading comments via R2. Used by callers that have just inserted\n * nodes which must not adopt a preceding block.\n */\nexport function resolveGroups(\n container: Document | Table | TableArray,\n isEligibleForLeading: (member: TreeNode) => boolean = () => true,\n memberKey: (member: TreeNode) => string | undefined = getMemberKey\n): Group[] {\n // For a table body, comments on the header's own line (`[a] # hdr`) are\n // owned by the header itself (R1) — initialising to the header's end line\n // makes that fall out of the same check as ownership by a preceding row.\n const initialLastMemberEndLine = isDocument(container) ? 0 : container.key.loc.end.line;\n return scanGroups(container.items as TreeNode[], initialLastMemberEndLine, isEligibleForLeading, memberKey);\n}\n\n/**\n * The element-level analogue of resolveGroups, for a multi-line InlineTable or\n * InlineArray. Unlike Document/Table/TableArray, an inline container's own\n * `.items` can never hold a Comment (InlineTableItem/InlineArrayItem are both\n * InlineItem<...>) — the parser hoists interior comments out into the\n * *enclosing* Document/Table's `.items` instead (Background, case 4 in the\n * plan doc). `hostItems` is that enclosing container's `.items`; this merges\n * the comments physically inside `container`'s line range back in with\n * `container.items` (sorted into true reading order) before running the same\n * scan resolveGroups uses.\n *\n * There is no R6 analogue for bare array elements (they aren't `key = value`\n * shaped), but nothing here suppresses R6 for an InlineArray's own comments —\n * see docs/Comment-Ownership.md for why that's an accepted, untested edge\n * case rather than a deliberate rule.\n */\nexport function resolveInlineElementGroups(\n container: InlineTable | InlineArray,\n hostItems: TreeNode[]\n): Group[] {\n const interiorComments = hostItems.filter(\n (item): item is Comment =>\n isComment(item) &&\n (item.loc.start.line > container.loc.start.line ||\n (item.loc.start.line === container.loc.start.line && item.loc.start.column >= container.loc.start.column)) &&\n (item.loc.end.line < container.loc.end.line ||\n (item.loc.end.line === container.loc.end.line && item.loc.end.column <= container.loc.end.column))\n );\n\n const merged: TreeNode[] = [...(container.items as TreeNode[]), ...interiorComments].sort(\n (a, b) => a.loc.start.line - b.loc.start.line || a.loc.start.column - b.loc.start.column\n );\n\n return scanGroups(merged, container.loc.start.line, () => true);\n}\n\n/**\n * Finds the nearest Document/Table/TableArray ancestor whose OWN `.items`\n * holds the top-level Block from which `target` is reachable, following\n * KeyValue.value / InlineTable.items / InlineArray.items / InlineItem.item\n * links down through any nesting depth. This is where the parser files\n * comments hoisted out of `target` (Background, case 4) — regardless of how\n * deeply `target` is nested inside other inline containers, they always\n * flatten up to the same enclosing Document/Table.\n */\n/**\n * Finds the InlineItem that wraps `target` (an InlineTable/InlineArray)\n * inside its own parent container's items, searching the whole tree.\n */\nfunction findWrapperItem(root: TreeNode, target: TreeNode): InlineItem | undefined {\n function walk(node: TreeNode): InlineItem | undefined {\n if (isKeyValue(node)) return walk(node.value);\n if (!hasItems(node)) return undefined;\n for (const item of node.items as TreeNode[]) {\n if (isInlineItem(item) && item.item === target) return item;\n }\n for (const item of node.items as TreeNode[]) {\n const found = walk(isInlineItem(item) ? item.item : item);\n if (found) return found;\n }\n return undefined;\n }\n return walk(root);\n}\n\nexport function findHostContainer(root: Document, target: TreeNode): Document | Table | TableArray | undefined {\n function searchValue(value: TreeNode, container: Document | Table | TableArray): Document | Table | TableArray | undefined {\n if (value === target) return container;\n // An inline table's entries are InlineItems wrapping a KeyValue, so reaching anything\n // nested under one of its keys means stepping through that KeyValue's value. Without\n // this, `t = { xs = [...] }` never reaches `xs`'s array and the caller falls back to the\n // comment-oblivious path.\n if (isKeyValue(value)) return searchValue(value.value, container);\n if (isInlineTable(value) || isInlineArray(value)) {\n for (const inlineItem of (value as InlineTable | InlineArray).items) {\n if ((inlineItem as TreeNode) === target) return container;\n const found = searchValue(inlineItem.item, container);\n if (found) return found;\n }\n }\n return undefined;\n }\n\n function search(container: Document | Table | TableArray): Document | Table | TableArray | undefined {\n for (const item of container.items as TreeNode[]) {\n if (item === target) return container;\n if (isKeyValue(item)) {\n const found = searchValue(item.value, container);\n if (found) return found;\n } else if (isTable(item) || isTableArray(item)) {\n const found = search(item);\n if (found) return found;\n }\n }\n return undefined;\n }\n\n return search(root);\n}\n\n/**\n * R5, applied once as a general-purpose (non-destructive-to-text) pass: a\n * comment that visually introduces the next [table]/[[array]] block is\n * physically stored as a trailing item of the PREVIOUS block, because the\n * parser consumes everything up to the next `[` into the current table\n * (src/parse-toml.ts:517-524). This re-parents such blocks into Document.items,\n * immediately before the block they visually belong to.\n *\n * Mutates the tree; loc-preserving, so serialized output is unchanged. NOTE:\n * because the re-parenting is loc-preserving, a document normalized this way\n * no longer matches what re-parsing its own serialized text would produce\n * (the parser always re-derives the original, pre-normalization container\n * assignment from the text). Do not call this as a blanket pre-pass before\n * general patching — it is intended for callers that immediately consume the\n * result without round-tripping through text (e.g. a future reorder pass that\n * is about to change those lines anyway). For deletion, `removeMember` below\n * computes the same R5 ownership lazily and only mutates when a comment is\n * genuinely being deleted, which has no such divergence risk.\n */\nexport function normalizeSectionComments(document: Document): void {\n for (let i = 0; i < document.items.length; i++) {\n const block = document.items[i];\n if (!isTable(block) && !isTableArray(block)) continue;\n\n const nextBlock = document.items[i + 1];\n if (!nextBlock) continue;\n\n const runItems = trailingOwnedRun(block, nextBlock);\n if (!runItems) continue;\n\n const items = block.items as TreeNode[];\n items.splice(items.length - runItems.length, runItems.length);\n document.items.splice(i + 1, 0, ...runItems);\n recalcContainerEnd(block);\n\n i += runItems.length; // skip over the just-inserted comments\n }\n}\n\n/**\n * R5, computed lazily: if `container`'s trailing comment block is R2-adjacent\n * to `nextBlock` (and not R6-dead), returns it — these are the comments a\n * removal of `nextBlock` must take along, even though they physically live\n * in `container.items`. Returns undefined otherwise.\n */\nfunction trailingOwnedRun(container: Table | TableArray, nextBlock: TreeNode): Comment[] | undefined {\n const lastGroup = last(resolveGroups(container));\n if (!lastGroup || lastGroup.kind !== 'pinned') return undefined;\n\n const runItems = lastGroup.items as Comment[];\n const adjacent = lastGroup.endLine + 1 === nextBlock.loc.start.line;\n const allDead = runItems.every(isCommentedOutEntry);\n if (!adjacent || allDead) return undefined;\n\n return runItems;\n}\n\n/**\n * Removes `member` from `parent.items` along with every comment it owns\n * (leading block and trailing comments — see resolveGroups), plus,\n * when `member` is a [table]/[[array]] block, any trailing comment block the\n * parser filed under the PRECEDING sibling table but which R5 assigns to\n * `member` instead. Falls back to a plain removal when `parent` isn't a\n * container the ownership model applies to (e.g. InlineTable/InlineArray).\n */\nexport function removeMember(root: Root, parent: TreeNode, member: TreeNode): void {\n if (isDocument(parent) && (isTable(member) || isTableArray(member))) {\n const index = (parent.items as TreeNode[]).indexOf(member);\n const previousSibling = index > 0 ? parent.items[index - 1] : undefined;\n if (previousSibling && (isTable(previousSibling) || isTableArray(previousSibling))) {\n const runItems = trailingOwnedRun(previousSibling, member);\n if (runItems) {\n for (const item of runItems) {\n remove(root, previousSibling, item);\n }\n }\n }\n }\n\n if (isDocument(parent) || isTable(parent) || isTableArray(parent)) {\n const group = resolveGroups(parent).find(s => s.member === member);\n if (group) {\n const memberIndex = group.items.indexOf(member);\n\n // Leading comments and the member itself: every one of these occupies\n // its own line(s) that the member's own span does not otherwise cover,\n // so each is removed via the generic primitive, which computes real\n // line/column offset accounting.\n for (let i = 0; i <= memberIndex; i++) {\n const item = group.items[i];\n // A prior remove() call in this loop may already have absorbed a\n // same-line trailing comment via its own single-comment logic —\n // see the trailing-comments loop below for why that's fine.\n if (!(parent.items as TreeNode[]).includes(item)) continue;\n remove(root, parent, item);\n }\n\n // Trailing (R1) comments: by definition their start line\n // is <= the member's own end line, so they sit *within* the span the\n // member's removal above already accounted for (a same-line trailing\n // comment, or one hoisted out of a multiline inline value). remove()'s\n // own legacy same-line check may already have absorbed a simple\n // trailing comment as a side effect of removing the member. Anything\n // still present here is spliced out directly, with NO further offset —\n // registering one would double-count a line height already removed.\n for (let i = memberIndex + 1; i < group.items.length; i++) {\n const item = group.items[i];\n const idx = (parent.items as TreeNode[]).indexOf(item);\n if (idx < 0) continue;\n (parent.items as TreeNode[]).splice(idx, 1);\n }\n return;\n }\n }\n\n if (isMultilineInlineContainer(parent) && isDocument(root)) {\n const hostContainer = findHostContainer(root, parent);\n if (hostContainer) {\n const group = resolveInlineElementGroups(parent, hostContainer.items as TreeNode[]).find(s => s.member === member);\n if (group) {\n const comments = group.items.filter(item => item !== member) as Comment[];\n\n // Every comment in this group is hoisted into hostContainer (the\n // enclosing Document/Table) — a DIFFERENT array from the member's own\n // `parent.items`, and NOT a sibling of it: hostContainer.items holds\n // the KeyValue that owns `parent` as its value, so an offset\n // registered there only ever affects that KeyValue's OWN siblings\n // (e.g. a later root key), never the surviving rows still inside\n // `parent` (a descendant of that KeyValue, not a sibling). Splicing\n // the comments out directly here (zero offset — purely structural),\n // then extending the member's own loc to cover their lines before\n // removing IT, lets remove()'s existing target-selection (a\n // preceding sibling row within `parent`, or an ENTER offset on\n // `parent` itself when the member is first) correctly propagate ONE\n // combined height reduction to both `parent`'s remaining rows and\n // whatever comes after it — it only needs the full height, comments\n // included, in a single call. `member` is being discarded regardless,\n // so mutating its own loc here has no lasting effect.\n for (const comment of comments) {\n const idx = (hostContainer.items as TreeNode[]).indexOf(comment);\n if (idx < 0) continue;\n (hostContainer.items as TreeNode[]).splice(idx, 1);\n }\n\n if (comments.length) {\n member.loc.start = group.items[0].loc.start;\n member.loc.end = last(group.items)!.loc.end;\n }\n\n remove(root, parent, member, hostContainer.items as TreeNode[]);\n\n // Flush immediately, matching moveInlineElement's identical discipline (see\n // its docstring): writer.remove()'s own orphaned-comment compensation above\n // mutates surviving comments' `.loc` as a PRE-compensation for an offset that\n // only actually resolves once applyWrites runs. If a SECOND removeMember (or\n // moveInlineElement) call on this same container ran before that offset were\n // resolved, resolveInlineElementGroups would read those pre-compensated,\n // not-yet-restored positions as if they were final — misattributing or\n // losing ownership. Flushing here keeps every subsequent call in this patch\n // starting from a fully-resolved, non-stale state.\n applyWrites(root);\n return;\n }\n }\n }\n\n remove(root, parent, member);\n}\n\n/**\n * Relocates `node` (an element of `parent`, an InlineTable/InlineArray) from\n * its current position to `toIndex`, carrying its own owned comments along\n * (see resolveInlineElementGroups) rather than leaving them at their old\n * absolute position — which is what plain remove()+insert() does, and why a\n * Move on a commented inline array can misplace a comment onto an unrelated\n * line (see \"Elements inside multi-line arrays and inline tables\" in\n * docs/Comment-Ownership.md).\n *\n * It isn't enough to protect only `node`'s own comments: writer.remove()'s\n * per-container \"orphaned comment\" cleanup reasons purely by absolute line\n * number, with no notion of ownership, so relocating `node` past *other*\n * elements can drag an unrelated element's own comment along as a side\n * effect (or leave it stranded) even though that element never moved. Every\n * commented element in the container is protected the same way: its\n * comment(s) are detached before the move and re-attached afterward, based\n * on how far *that specific element* actually shifted — which may differ\n * from how far `node` itself moved, or be zero.\n */\nexport function moveInlineElement(root: Root, parent: TreeNode, node: TreeNode, toIndex: number): void {\n let sharedLineContainerBeforeMove = false;\n if (isMultilineInlineContainer(parent) && isDocument(root)) {\n const hostContainer = findHostContainer(root, parent);\n if (hostContainer) {\n const groups = resolveInlineElementGroups(parent, hostContainer.items as TreeNode[]);\n\n // The container's per-line vs shared-line layout must be judged on\n // the state BEFORE this move: remove()+insert() inflate the tail's\n // line coordinates, and a later perLine() read of the corrupted span\n // misclassifies a shared-line container as per-line, skipping the\n // tail realignment and stranding the rows (fuzz seed 16034).\n //\n // The honest signature of a shared-line layout is a RUN of at least\n // three adjacent items STARTING on the same line. Two items sharing\n // a line is the signature of a per-line container whose multiline\n // member ends on the next item's line — the writer offsets handle\n // those (fuzz seeds 9553, 9829). A same-line pair caused by a\n // just-inserted item still carrying its pending exit offset is\n // transient and must not count (fuzz seed 761).\n {\n const items = (parent as InlineTable | InlineArray).items as TreeNode[];\n let run = 1;\n for (let i = 1; i < items.length; i++) {\n if (items[i].loc.start.line === items[i - 1].loc.start.line) {\n const prevPending = getExitOffsets(root).get(items[i - 1]);\n const selfPending = getExitOffsets(root).get(items[i]);\n if (prevPending || selfPending) continue;\n run++;\n if (run >= 3) {\n sharedLineContainerBeforeMove = true;\n break;\n }\n } else {\n run = 1;\n }\n }\n }\n\n const detached: Array<{ owner: TreeNode; ownerOriginalStart: { line: number; column: number }; comments: Comment[] }> = [];\n let nodeOwnStart: { line: number; column: number } | undefined;\n let nodeOwnEnd: { line: number; column: number } | undefined;\n let nodeInnerEnd: { line: number; column: number } | undefined;\n\n // Snapshot descendants of the moved node that start BELOW its first\n // line. insert()'s rigid horizontal translation shifts every subtree\n // column by the first line's column delta, but interior rows of a\n // multiline inline table/array are indented from line start (not from\n // the opening bracket), so they must not move sideways. This covers\n // both rows anchored to a preceding multiline value's end column\n // (fuzz seed 706: `, 5, 6` after a multiline string inside a moved\n // nested array slid left onto the string's closing quotes) and the\n // FIRST row of a multiline container that has no predecessor at all\n // (fuzz seed 599513: `nxweV7FF3` slid to a negative column and toTOML\n // emitted `,-1.5nx=`).\n const anchoredDescendants: Array<{ node: TreeNode; start: { line: number; column: number }; end: { line: number; column: number }; endOnly?: boolean; equals?: number }> = [];\n const collectAnchored = (container: TreeNode, firstLine: number) => {\n if (!hasItems(container)) return;\n const items = container.items as TreeNode[];\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const below = item.loc.start.line > firstLine;\n if (below) {\n anchoredDescendants.push({ node: item, start: clonePosition(item.loc.start), end: clonePosition(item.loc.end) });\n }\n // A multiline element's wrapper END (where its comma lands) is\n // anchored to the element's own end column, which the leaf path of\n // the rigid translation leaves alone — but the wrapper's end is\n // shifted with the first line. Restore it too.\n if (item.loc.end.line > firstLine && item.loc.end.line > item.loc.start.line) {\n anchoredDescendants.push({ node: item, start: clonePosition(item.loc.start), end: clonePosition(item.loc.end), endOnly: true });\n }\n if (isInlineItem(item)) {\n const inner = item.item;\n if (below) {\n const kv = isKeyValue(inner) ? inner : undefined;\n anchoredDescendants.push({\n node: inner,\n start: clonePosition(inner.loc.start),\n end: clonePosition(inner.loc.end),\n equals: kv ? kv.equals : undefined\n });\n // The KV's key and value nodes ride the same rigid translation\n // as the row, but only the row and the KV are restored above —\n // the key keeps its shifted column and toTOML writes it at its\n // own loc, overwriting the preceding content (fuzz seed 19506).\n if (kv) {\n anchoredDescendants.push({\n node: kv.key,\n start: clonePosition(kv.key.loc.start),\n end: clonePosition(kv.key.loc.end)\n });\n anchoredDescendants.push({\n node: kv.value,\n start: clonePosition(kv.value.loc.start),\n end: clonePosition(kv.value.loc.end)\n });\n }\n }\n // A multiline STRING's own end column is what its closing quotes\n // follow — offsets can nudge it while the wrapper's end (with the\n // comma) stays put, making toTOML's multiline writer consume the\n // columns between them (fuzz seed 706). Restore it independently.\n if (inner.loc.end.line > firstLine && inner.loc.end.line > inner.loc.start.line) {\n anchoredDescendants.push({ node: inner, start: clonePosition(inner.loc.start), end: clonePosition(inner.loc.end), endOnly: true });\n }\n collectAnchored(inner, firstLine);\n } else if (hasItems(item)) {\n collectAnchored(item, firstLine);\n }\n }\n };\n\n for (const group of groups) {\n if (group.kind !== 'member' || !group.member) continue;\n const comments = group.items.filter(item => item !== group.member) as Comment[];\n\n if (group.member === node) {\n nodeOwnStart = clonePosition(node.loc.start);\n nodeOwnEnd = clonePosition(node.loc.end);\n if (isInlineItem(node)) {\n nodeInnerEnd = clonePosition(node.item.loc.end);\n }\n collectAnchored(isInlineItem(node) ? node.item : node, nodeOwnStart.line);\n if (comments.length) {\n // Extend node's own loc to the full group span so the bare\n // remove()+insert() below accounts for the combined height —\n // matters for a leading, separate-line comment; a no-op for a\n // same-line trailing one, since that doesn't change the line\n // count (mirrors removeMember's identical trick).\n node.loc.start = clonePosition(group.items[0].loc.start);\n node.loc.end = clonePosition(last(group.items)!.loc.end);\n }\n }\n\n if (!comments.length) continue;\n detached.push({ owner: group.member, ownerOriginalStart: clonePosition(group.member.loc.start), comments });\n for (const comment of comments) {\n const idx = (hostContainer.items as TreeNode[]).indexOf(comment);\n if (idx >= 0) (hostContainer.items as TreeNode[]).splice(idx, 1);\n }\n }\n\n // For a multiline item removed from the END of a shared-line container,\n // remove()'s bracket-slide offset (fuzz seed 706) mixes the removed\n // item's LAST line with the previous item's line. The re-insert below\n // cannot cancel it — its own span-based offset has the same cross-line\n // defect — so the pair leaks past the container and corrupts every\n // subsequent node on the flush (fuzz seed 900: the rows after the array\n // slid onto the multiline string's content). Drop both; the tail\n // realignment below repositions the container's interior explicitly.\n const nodeIndexBeforeRemove = (parent.items as TreeNode[]).indexOf(node);\n const removedWasLast = nodeIndexBeforeRemove === (parent.items as TreeNode[]).length - 1;\n const prevBeforeRemove = nodeIndexBeforeRemove > 0\n ? (parent.items as TreeNode[])[nodeIndexBeforeRemove - 1]\n : undefined;\n\n // A multiline node moved to the FRONT (index 0) that, before the move,\n // shared its START line with the item now following it (`prevBeforeRemove`,\n // which ends up at index 1). The writer's per-line offset model assumes\n // each item sits on its own line, so the shared-line item's columns go\n // stale (it lands with a negative start column, overwriting the moved\n // multiline string's closing delimiter). The tail realignment below is\n // gated on `sharedLineContainerBeforeMove`, which a two-item same-line\n // pairing does NOT satisfy — so record this case explicitly (fuzz seed\n // 421965: `[false, \"\"\"\\nAAA\\n\"\"\", \"z\"]` moving the string to the front\n // left `false` at column -2 on the string's last line).\n const movedMultilineToFront = toIndex === 0 && nodeIndexBeforeRemove > 0 &&\n node.loc.end.line > node.loc.start.line &&\n prevBeforeRemove !== undefined &&\n prevBeforeRemove.loc.start.line === node.loc.start.line;\n\n remove(root, parent, node, hostContainer.items as TreeNode[]);\n\n let cancelMultilineLastRemovalOffsets = false;\n if (removedWasLast && prevBeforeRemove !== undefined &&\n node.loc.end.line > node.loc.start.line &&\n !perLine(parent as InlineArray | InlineTable)) {\n const prevPending = getExitOffsets(root).get(prevBeforeRemove);\n if (prevPending) {\n getExitOffsets(root).delete(prevBeforeRemove);\n cancelMultilineLastRemovalOffsets = true;\n }\n }\n\n // Resolve the removal's offsets before re-inserting, so insert()\n // measures against final positions. Otherwise insert() absorbs the\n // removal's pending exit offset into the inserted item's own offset,\n // which then leaks into the container's end column (and any wrapper\n // InlineItem's end) — a comma or closing bracket lands inside the\n // last value on that line (fuzz seed 50).\n applyWrites(root);\n insert(root, parent, node, toIndex, undefined, hostContainer.items as TreeNode[]);\n\n if (cancelMultilineLastRemovalOffsets) {\n const childPending = getExitOffsets(root).get(node);\n if (childPending) {\n childPending.lines = 0;\n childPending.columns = 0;\n }\n }\n\n // Flush before reading anything back out below. Every other element's\n // own loc (an untouched sibling that nonetheless shifted because this\n // move made room around it) only becomes fully current at this point,\n // and it's what each owner's delta below is computed against. It also\n // means any FURTHER change in this patch touching the same container\n // starts from a fully-resolved, non-stale state.\n applyWrites(root);\n\n // insert() translates the node rigidly: every line of a multi-line\n // node receives the first line's column delta. A multi-line value's\n // content columns below the first line are part of its raw text and\n // must not move — the writer only reads the END column on the last\n // line, so restore just that, on both the wrapper InlineItem and the\n // inner value node it wraps (fuzz seed 50).\n if (nodeOwnStart && nodeOwnEnd && node.loc.end.line > node.loc.start.line) {\n node.loc.end.column = nodeOwnEnd.column;\n // The inner value keeps its OWN original end — for a multiline\n // string the wrapper's end includes the comma that follows, and\n // assigning it to the string makes toTOML's multiline writer\n // consume the columns between the closing quotes and the next item\n // (fuzz seed 706).\n if (isInlineItem(node) && nodeInnerEnd && node.item.loc.end.line > node.item.loc.start.line) {\n node.item.loc.end.column = nodeInnerEnd.column;\n }\n }\n\n // Restore the columns of anchored below-first-line descendants that the\n // rigid translation shifted horizontally (see the snapshot comment above).\n for (const { node: descendant, start, end, endOnly, equals } of anchoredDescendants) {\n if (endOnly) {\n descendant.loc.end.column = end.column;\n continue;\n }\n descendant.loc.start.column = start.column;\n if (descendant.loc.end.line === descendant.loc.start.line) {\n descendant.loc.end.column = end.column;\n }\n if (equals !== undefined && isKeyValue(descendant)) {\n (descendant as KeyValue).equals = equals;\n }\n }\n\n for (const { owner, ownerOriginalStart, comments } of detached) {\n let delta: { lines: number; columns: number };\n if (owner === node) {\n // node.loc is still the (possibly extended) relocated group span;\n // derive the shift from that, then restore node's own bare span.\n delta = {\n lines: node.loc.start.line - ownerOriginalStart.line,\n columns: node.loc.start.column - ownerOriginalStart.column\n };\n node.loc.start = { line: nodeOwnStart!.line + delta.lines, column: nodeOwnStart!.column + delta.columns };\n node.loc.end = { line: nodeOwnEnd!.line + delta.lines, column: nodeOwnEnd!.column + delta.columns };\n } else {\n delta = {\n lines: owner.loc.start.line - ownerOriginalStart.line,\n columns: owner.loc.start.column - ownerOriginalStart.column\n };\n }\n\n for (const comment of comments) {\n shiftNode(comment, delta);\n const insertAt = (hostContainer.items as TreeNode[]).findIndex(\n item => item.loc.start.line > comment.loc.start.line\n );\n if (insertAt === -1) (hostContainer.items as TreeNode[]).push(comment);\n else (hostContainer.items as TreeNode[]).splice(insertAt, 0, comment);\n }\n }\n\n // The writer's offset model assumes the next sibling sits at the moved\n // node's first-line column. When the moved node wraps lines (a\n // multiline string) inside a container whose items share lines, that\n // assumption breaks and every item after the moved one lands in the\n // wrong place, dragging the container's (and any wrapper InlineItem's)\n // end column with it. Realign the tail sequentially: each item starts\n // right after the previous one's end (fuzz seed 50).\n const container = parent as InlineTable | InlineArray;\n // Gate the tail realignment on the original layout classification:\n // perLine() reads the container's own end, which the moves above can\n // leave stale. The pre-move capture reflects the true layout. A\n // multiline node moved to the front also needs the tail realignment\n // (see movedMultilineToFront above), even though the shared-line run\n // is only two items and `sharedLineContainerBeforeMove` stays false.\n const sharedLineContainer = sharedLineContainerBeforeMove || movedMultilineToFront;\n if (sharedLineContainer) {\n // Re-anchor the interior rows of a multiline inline container whose\n // subtree the tail shift above translated rigidly: the shiftNode\n // moves every row's START, but rows anchored to a preceding\n // multiline value keep their END columns — the boundary between a\n // multiline string row and the next row then closes up and the\n // separator comma is overwritten (fuzz seed 16552).\n const realignInterior = (inner: InlineTable | InlineArray, wrapper?: TreeNode) => {\n let anchor: { line: number; column: number } | undefined;\n for (const row of inner.items as TreeNode[]) {\n if (!anchor) {\n anchor = { line: row.loc.end.line, column: row.loc.end.column + 2 };\n continue;\n }\n const d = {\n lines: anchor.line - row.loc.start.line,\n columns: anchor.column - row.loc.start.column\n };\n if (d.lines !== 0 || d.columns !== 0) {\n shiftNode(row, d);\n if (row.loc.end.line > row.loc.start.line) {\n row.loc.end.column -= d.columns;\n if (isInlineItem(row) && row.item.loc.end.line > row.item.loc.start.line) {\n row.item.loc.end.column -= d.columns;\n }\n }\n const rowInner = isInlineItem(row)\n ? (isKeyValue(row.item) ? row.item.value : row.item)\n : row;\n if ((isInlineTable(rowInner) || isInlineArray(rowInner)) &&\n rowInner.loc.end.line > rowInner.loc.start.line) {\n realignInterior(rowInner, row);\n }\n }\n anchor = { line: row.loc.end.line, column: row.loc.end.column + 2 };\n }\n if (anchor) {\n inner.loc.end = { line: anchor.line, column: anchor.column - 1 };\n // The enclosing InlineItem's end carries the comma that follows\n // the closing brace — track the new end so the comma stays\n // adjacent (fuzz seed 16552).\n if (wrapper && wrapper.loc.end.line === inner.loc.end.line) {\n wrapper.loc.end.column = inner.loc.end.column;\n }\n }\n };\n\n let tailAnchor: { line: number; column: number } | undefined;\n for (const item of container.items as TreeNode[]) {\n if (item === node) {\n tailAnchor = { line: node.loc.end.line, column: node.loc.end.column + 2 };\n continue;\n }\n if (!tailAnchor) continue;\n const delta = {\n lines: tailAnchor.line - item.loc.start.line,\n columns: tailAnchor.column - item.loc.start.column\n };\n if (delta.lines !== 0 || delta.columns !== 0) {\n shiftNode(item, delta);\n const itemInner = isInlineItem(item)\n ? (isKeyValue(item.item) ? item.item.value : item.item)\n : item;\n if ((isInlineTable(itemInner) || isInlineArray(itemInner)) &&\n itemInner.loc.end.line > itemInner.loc.start.line) {\n realignInterior(itemInner, isInlineItem(item) ? item : undefined);\n }\n }\n // A multiline STRING member's end line may be stale (the move\n // offsets inflated it) — derive it from the raw content so the\n // chain doesn't push the following items onto the wrong lines\n // (fuzz seed 9553).\n let itemEndLine = item.loc.end.line;\n const tailInner = isInlineItem(item) ? item.item : item;\n if (isString(tailInner) && tailInner.loc.end.line > tailInner.loc.start.line) {\n itemEndLine = tailInner.loc.start.line + tailInner.raw.split('\\n').length - 1;\n tailInner.loc.end.line = itemEndLine;\n item.loc.end.line = itemEndLine;\n }\n tailAnchor = { line: itemEndLine, column: item.loc.end.column + 2 };\n }\n if (tailAnchor) {\n const endBeforeRealign = clonePosition(container.loc.end);\n container.loc.end = { line: tailAnchor.line, column: tailAnchor.column - 1 };\n\n // The container may itself be an element of another inline\n // container; the wrapper InlineItem's end must track the\n // container's end or its comma lands inside the last value.\n const wrapper = findWrapperItem(root, container as TreeNode);\n if (wrapper) {\n wrapper.loc.end = { line: container.loc.end.line, column: container.loc.end.column };\n }\n\n // Nodes AFTER the container (same-line followers, enclosing\n // table rows, the table's own end) were positioned by the writer\n // offsets this realignment has just replaced. Re-anchor them to\n // the new end with a pending exit offset so a later flush shifts\n // them by exactly the end delta (fuzz seed 900: the row following\n // the moved array would otherwise sit on the moved item's stale\n // column and the subsequent removal then slides it sideways onto\n // the multiline string's content).\n const endDelta = {\n lines: container.loc.end.line - endBeforeRealign.line,\n columns: container.loc.end.column - endBeforeRealign.column\n };\n if (endDelta.lines !== 0 || endDelta.columns !== 0) {\n addExitOffset(root, wrapper ?? (container as TreeNode), endDelta);\n }\n }\n }\n\n return;\n }\n }\n\n // Capture the container's bracket gaps before the move so they can be\n // restored afterwards. remove()+insert() uses writer offsets that do\n // not perfectly cancel over consecutive Moves on the same container,\n // which corrupts the leading gap (space after `[`/`{`) and trailing gap\n // (space before `]`/`}`).\n const container = parent as InlineTable | InlineArray;\n const itemsBefore = container.items as TreeNode[];\n const firstBefore = itemsBefore[0];\n const lastBefore = itemsBefore[itemsBefore.length - 1];\n const originalLeadingGap = firstBefore.loc.start.column - container.loc.start.column - 1;\n const originalTrailingGap = container.loc.end.column - 1 - lastBefore.loc.end.column;\n\n remove(root, parent, node);\n insert(root, parent, node, toIndex);\n\n // Flush so consecutive Moves start from resolved positions (prevents\n // exit-offset accumulation on the same target) and so the gap\n // measurements below see final positions.\n applyWrites(root);\n\n // Restore bracket gaps corrupted by the move's offsets.\n const itemsAfter = container.items as TreeNode[];\n const firstAfter = itemsAfter[0];\n const leadingGap = firstAfter.loc.start.column - container.loc.start.column - 1;\n if (leadingGap !== originalLeadingGap) {\n shiftNode(firstAfter, {\n lines: 0,\n columns: originalLeadingGap - leadingGap\n });\n }\n const lastAfter = itemsAfter[itemsAfter.length - 1];\n const trailingGap = container.loc.end.column - 1 - lastAfter.loc.end.column;\n if (trailingGap !== originalTrailingGap) {\n container.loc.end.column = lastAfter.loc.end.column + 1 + originalTrailingGap;\n }\n}\n"],"mappings":";;;;;;;AA6BA,MAAM,cAAc,OAAO,GAAG;;AAG9B,MAAa,6BACX,IAAI,OAAO,OAAO,GAAG,QAAQ,YAAY,aAAa,YAAY,OAAO;;;;;AAM3E,MAAM,cAAc,OAAO,GAAG;;AAG9B,MAAM,2BACJ,IAAI,OAAO,OAAO,GAAG,QAAQ,YAAY,aAAa,YAAY,WAAW,YAAY,KAAK;;AAGhG,MAAa,0BACX,IAAI,OAAO,OAAO,GAAG,gBAAgB,YAAY,aAAa,YAAY,eAAe;AAE3F,SAAgB,oBAAoB,SAA2B;CAC7D,OAAO,yBAAyB,KAAK,QAAQ,GAAG,KAAK,wBAAwB,KAAK,QAAQ,GAAG;AAC/F;;;;;;;AAQA,SAAS,2BAA2B,SAA2B;CAC7D,MAAM,QAAQ,QAAQ,IAAI,QAAQ,GAAG;CACrC,IAAI,QAAQ,GAAG,OAAO;CACtB,IAAI,WAAW;CACf,IAAI,WAAW;CACf,KAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,QAAQ,IAAI,QAAQ,KAAK;EACnD,MAAM,KAAK,QAAQ,IAAI;EACvB,IAAI,OAAO,MAAM;GAAE;GAAK;EAAU;EAClC,IAAI,CAAC,YAAY,OAAO,MAAK;GAAE,WAAW,CAAC;GAAU;EAAU;EAC/D,IAAI,CAAC,YAAY,OAAO,KAAK;GAAE,WAAW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,SAAS;CAC9E,IAAI,eAAe,oBACjB,UAAU,YAAY;EACpB,OAAO;EACP,SAAS,qBAAqB;CAChC,CAAC;CAEH,MAAM,YAAY,WAAW,WAAW,SAAS;CAEjD,IADoB,UAAU,IAAI,IAAI,SAAS,IAAI,UAAU,IAAI,IAAI,WACjD,qBAClB,UAAU,IAAI,IAAI,SAAS,UAAU,IAAI,IAAI,SAAS,IAAI;AAE9D"}
|
package/dist/dev/cst-source.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.1.
|
|
1
|
+
//! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
import { hasItems, isInlineItem, isKeyValue, isTable, isTableArray } from "./cst.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cst-source.ts
|