From 84cb001dd6aafced5e268225b2e0f8206ff72394 Mon Sep 17 00:00:00 2001 From: m3taversal Date: Sat, 4 Apr 2026 14:01:34 +0100 Subject: [PATCH] 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) --- lib/merge.py | 4 ++-- tests/test_reweave_merge.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/merge.py b/lib/merge.py index 8a8139b..866adf8 100644 --- a/lib/merge.py +++ b/lib/merge.py @@ -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, []) diff --git a/tests/test_reweave_merge.py b/tests/test_reweave_merge.py index f19c398..e1af896 100644 --- a/tests/test_reweave_merge.py +++ b/tests/test_reweave_merge.py @@ -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: