fix: handle indented YAML list items in _serialize_edge_fields

The skip loop only matched `- ` (no indent) but YAML list items are
commonly written as `  - item` (2-space indent). This caused old list
items to persist alongside new ones, corrupting frontmatter on merge.

Fix: consume any line starting with space or dash as part of the current
field's value block.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
m3taversal 2026-04-04 14:01:34 +01:00
parent 16e798f6a2
commit 84cb001dd6
2 changed files with 3 additions and 3 deletions

View file

@ -466,9 +466,9 @@ def _serialize_edge_fields(raw_fm_text: str, merged_edges: dict[str, list]) -> s
if matched_field:
fields_written.add(matched_field)
# Skip the old field and its list items
# Skip the old field and its list items (may be indented with spaces)
i += 1
while i < len(lines) and lines[i].startswith("- "):
while i < len(lines) and lines[i] and (lines[i][0] in (' ', '-')):
i += 1
# Write the merged version
edges = merged_edges.get(matched_field, [])

View file

@ -61,7 +61,7 @@ def _serialize_edge_fields(raw_fm_text: str, merged_edges: dict[str, list]) -> s
if matched_field:
fields_written.add(matched_field)
i += 1
while i < len(lines) and lines[i].startswith("- "):
while i < len(lines) and lines[i] and (lines[i][0] in (' ', '-')):
i += 1
edges = merged_edges.get(matched_field, [])
if edges: