fix(hashline-edit): address Cubic review issues - boundary echo, chunking dedup, empty stream alignment

- Fix single-line anchor-echo stripping to trigger empty-insert validation

- Fix trailing boundary-echo stripping for boundary-only payloads

- Extract shared chunking logic to hashline-chunk-formatter

- Align empty stream/iterable handling with formatHashLines

- Add regression tests for all fixes
This commit is contained in:
YeonGyu-Kim
2026-02-22 03:54:31 +09:00
parent 8f424de41b
commit 2615fd0d73
5 changed files with 112 additions and 84 deletions
@@ -57,7 +57,7 @@ export function restoreLeadingIndent(templateLine: string, line: string): string
}
export function stripInsertAnchorEcho(anchorLine: string, newLines: string[]): string[] {
if (newLines.length <= 1) return newLines
if (newLines.length === 0) return newLines
if (equalsIgnoringWhitespace(newLines[0], anchorLine)) {
return newLines.slice(1)
}
@@ -74,10 +74,10 @@ export function stripInsertBeforeEcho(anchorLine: string, newLines: string[]): s
export function stripInsertBoundaryEcho(afterLine: string, beforeLine: string, newLines: string[]): string[] {
let out = newLines
if (out.length > 1 && equalsIgnoringWhitespace(out[0], afterLine)) {
if (out.length > 0 && equalsIgnoringWhitespace(out[0], afterLine)) {
out = out.slice(1)
}
if (out.length > 1 && equalsIgnoringWhitespace(out[out.length - 1], beforeLine)) {
if (out.length > 0 && equalsIgnoringWhitespace(out[out.length - 1], beforeLine)) {
out = out.slice(0, -1)
}
return out