MCPcopy Index your code
hub / github.com/coder/coder / endingsMatch

Function endingsMatch

agent/agentfiles/files.go:647–657  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

645// matches any ending, which lets the splice later substitute the
646// file's actual ending in place of a missing one.
647func 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

Callers 1

fuzzyReplaceFunction · 0.85

Calls 1

isNewlineEndingFunction · 0.85

Tested by

no test coverage detected