endingsMatch decides whether two line endings may pair up during fuzzy matching. Identical endings always match. "\n" and "\r\n" interchange so LLMs can send LF searches against CRLF content. An empty ending (EOF, no terminator) acts as a wildcard and matches any ending, which lets the splice later
(a, b string)
| 645 | // matches any ending, which lets the splice later substitute the |
| 646 | // file's actual ending in place of a missing one. |
| 647 | func endingsMatch(a, b string) bool { |
| 648 | // Wildcard: empty ending matches any ending at the matching |
| 649 | // phase. Only valid here, not at the splice phase. |
| 650 | if a == "" || b == "" { |
| 651 | return true |
| 652 | } |
| 653 | if a == b { |
| 654 | return true |
| 655 | } |
| 656 | return isNewlineEnding(a) && isNewlineEnding(b) |
| 657 | } |
| 658 | |
| 659 | // isNewlineEnding reports whether s is one of the newline-class |
| 660 | // endings: "\n" or "\r\n". Shared primitive for endingsMatch |
no test coverage detected