MCPcopy Create free account
hub / github.com/cogentcore/core / SplitLines

Function SplitLines

texteditor/difflib/bytes/bytes.go:1122–1126  ·  view source on GitHub ↗

SplitLines splits a []byte on "\n" while preserving them. The output can be used as input for UnifiedDiff and ContextDiff structures.

(s []byte)

Source from the content-addressed store, hash-verified

1120// SplitLines splits a []byte on "\n" while preserving them. The output can be used
1121// as input for UnifiedDiff and ContextDiff structures.
1122func SplitLines(s []byte) [][]byte {
1123 lines := bytes.SplitAfter(s, []byte("\n"))
1124 lines[len(lines)-1] = append(lines[len(lines)-1], '\n')
1125 return lines
1126}

Calls

no outgoing calls

Tested by 9

TestOmitFilenamesFunction · 0.56
TestSplitLinesFunction · 0.56
benchmarkSplitLinesFunction · 0.56
TestGetUnifiedDiffStringFunction · 0.56