(lines: string[], pattern: string[], startIndex: number, eof = false)
| 458 | } |
| 459 | |
| 460 | function seekSequence(lines: string[], pattern: string[], startIndex: number, eof = false): number { |
| 461 | if (pattern.length === 0) return -1 |
| 462 | |
| 463 | // Pass 1: exact match |
| 464 | const exact = tryMatch(lines, pattern, startIndex, (a, b) => a === b, eof) |
| 465 | if (exact !== -1) return exact |
| 466 | |
| 467 | // Pass 2: rstrip (trim trailing whitespace) |
| 468 | const rstrip = tryMatch(lines, pattern, startIndex, (a, b) => a.trimEnd() === b.trimEnd(), eof) |
| 469 | if (rstrip !== -1) return rstrip |
| 470 | |
| 471 | // Pass 3: trim (both ends) |
| 472 | const trim = tryMatch(lines, pattern, startIndex, (a, b) => a.trim() === b.trim(), eof) |
| 473 | if (trim !== -1) return trim |
| 474 | |
| 475 | // Pass 4: normalized (Unicode punctuation to ASCII) |
| 476 | const normalized = tryMatch( |
| 477 | lines, |
| 478 | pattern, |
| 479 | startIndex, |
| 480 | (a, b) => normalizeUnicode(a.trim()) === normalizeUnicode(b.trim()), |
| 481 | eof, |
| 482 | ) |
| 483 | return normalized |
| 484 | } |
| 485 | |
| 486 | function generateUnifiedDiff(oldContent: string, newContent: string): string { |
| 487 | const oldLines = oldContent.split("\n") |
no test coverage detected