fix(hashline-edit): align autocorrect, BOM/CRLF, and tool description with oh-my-pi
- Rewrite restoreOldWrappedLines to use oh-my-pi's span-scanning algorithm - Add stripTrailingContinuationTokens and stripMergeOperatorChars helpers - Fix detectLineEnding to use first-occurrence logic instead of any-match - Fix applyAppend/applyPrepend to replace empty-line placeholder in empty files - Enhance tool description with 7 critical rules, tag guidance, and anti-patterns
This commit is contained in:
@@ -134,6 +134,9 @@ export function applyAppend(lines: string[], text: string | string[]): string[]
|
||||
if (normalized.length === 0) {
|
||||
throw new Error("append requires non-empty text")
|
||||
}
|
||||
if (lines.length === 1 && lines[0] === "") {
|
||||
return [...normalized]
|
||||
}
|
||||
return [...lines, ...normalized]
|
||||
}
|
||||
|
||||
@@ -142,6 +145,9 @@ export function applyPrepend(lines: string[], text: string | string[]): string[]
|
||||
if (normalized.length === 0) {
|
||||
throw new Error("prepend requires non-empty text")
|
||||
}
|
||||
if (lines.length === 1 && lines[0] === "") {
|
||||
return [...normalized]
|
||||
}
|
||||
return [...normalized, ...lines]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user