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

Function splitEnding

agent/agentfiles/files.go:631–639  ·  view source on GitHub ↗

splitEnding separates a line produced by strings.SplitAfter(s, "\n") into its content bytes and its line ending. The ending is one of "\r\n", "\n", or "" (the last slice when the input lacks a trailing newline).

(line string)

Source from the content-addressed store, hash-verified

629// one of "\r\n", "\n", or "" (the last slice when the input lacks a
630// trailing newline).
631func splitEnding(line string) (content, ending string) {
632 if strings.HasSuffix(line, "\r\n") {
633 return line[:len(line)-2], "\r\n"
634 }
635 if strings.HasSuffix(line, "\n") {
636 return line[:len(line)-1], "\n"
637 }
638 return line, ""
639}
640
641// endingsMatch decides whether two line endings may pair up during
642// fuzzy matching. Identical endings always match. "\n" and "\r\n"

Callers 7

internalLineEndingFunction · 0.85
atNoNewlineEOFFunction · 0.85
alignSearchReplaceFunction · 0.85
rewriteInternalEndingFunction · 0.85
splitLinePartsFunction · 0.85
fuzzyReplaceFunction · 0.85
miscountHintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected