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

Function dominantFileEnding

agent/agentfiles/files.go:699–713  ·  view source on GitHub ↗

dominantFileEnding returns CRLF if CRLF endings outnumber LF in contentLines, LF otherwise (including ties and ending-less files).

(contentLines []string)

Source from the content-addressed store, hash-verified

697// dominantFileEnding returns CRLF if CRLF endings outnumber LF in
698// contentLines, LF otherwise (including ties and ending-less files).
699func dominantFileEnding(contentLines []string) string {
700 var crlf, lf int
701 for _, l := range contentLines {
702 switch {
703 case strings.HasSuffix(l, "\r\n"):
704 crlf++
705 case strings.HasSuffix(l, "\n"):
706 lf++
707 }
708 }
709 if crlf > lf {
710 return "\r\n"
711 }
712 return "\n"
713}
714
715// atNoNewlineEOF reports whether the matched region ends at a
716// file that lacks a trailing newline. True when no non-empty lines

Callers 1

fuzzyReplaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected