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

Function formatRangeUnified

texteditor/difflib/bytes/bytes.go:852–863  ·  view source on GitHub ↗

Convert range to the "ed" format

(start, stop int)

Source from the content-addressed store, hash-verified

850
851// Convert range to the "ed" format
852func formatRangeUnified(start, stop int) []byte {
853 // Per the diff spec at http://www.unix.org/single_unix_specification/
854 beginning := start + 1 // lines start numbering with one
855 length := stop - start
856 if length == 1 {
857 return []byte(fmt.Sprintf("%d", beginning))
858 }
859 if length == 0 {
860 beginning -= 1 // empty ranges begin at line just before the range
861 }
862 return []byte(fmt.Sprintf("%d,%d", beginning, length))
863}
864
865// UnifiedDiff contains unified diff parameters
866type UnifiedDiff struct {

Callers 1

WriteUnifiedDiffFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected