fix(#1103): preserve newline before Plans: header in roadmap.annotate-dependencies (#1111)

The match regex's `(?:^|\n)` anchor consumes a leading newline on mid-string
matches (the common case where a `**Plans:** N plans` summary line precedes a
bare `Plans:` block). The replacement dropped that newline, fusing the summary
line onto the header — e.g. `**Plans:** 3 plansPlans:`. Re-emit the consumed
newline so markdown line boundaries are preserved.

Closes #1103

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-06-12 15:54:25 -04:00
committed by GitHub
parent ed47ebd971
commit 4beceb02fe
3 changed files with 127 additions and 1 deletions

View File

@@ -730,9 +730,12 @@ function cmdRoadmapAnnotateDependencies(cwd: string, phaseNum: string | null | u
}
const newListBlock = annotatedLines.join('\n') + '\n';
// #1103: when `(?:^|\n)` consumed a leading `\n` (mid-string match), re-emit it
// so the line preceding the Plans: header is not fused onto it.
const leadingNewline = plansBlockMatch[0].startsWith('\n') ? '\n' : '';
const newPhaseSection = phaseSection.replace(
plansBlockMatch[0],
plansHeader + newListBlock
leadingNewline + plansHeader + newListBlock
);
const nextContent = content.slice(0, phaseStart) + newPhaseSection + content.slice(phaseEnd);