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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user