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:
@@ -5,7 +5,11 @@ export interface FileTextEnvelope {
|
||||
}
|
||||
|
||||
function detectLineEnding(content: string): "\n" | "\r\n" {
|
||||
return content.includes("\r\n") ? "\r\n" : "\n"
|
||||
const crlfIndex = content.indexOf("\r\n")
|
||||
const lfIndex = content.indexOf("\n")
|
||||
if (lfIndex === -1) return "\n"
|
||||
if (crlfIndex === -1) return "\n"
|
||||
return crlfIndex < lfIndex ? "\r\n" : "\n"
|
||||
}
|
||||
|
||||
function stripBom(content: string): { content: string; hadBom: boolean } {
|
||||
|
||||
Reference in New Issue
Block a user