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

Function formatRangeContext

texteditor/difflib/bytes/bytes.go:993–1004  ·  view source on GitHub ↗

Convert range to the "ed" format.

(start, stop int)

Source from the content-addressed store, hash-verified

991
992// Convert range to the "ed" format.
993func formatRangeContext(start, stop int) []byte {
994 // Per the diff spec at http://www.unix.org/single_unix_specification/
995 beginning := start + 1 // lines start numbering with one
996 length := stop - start
997 if length == 0 {
998 beginning -= 1 // empty ranges begin at line just before the range
999 }
1000 if length <= 1 {
1001 return []byte(fmt.Sprintf("%d", beginning))
1002 }
1003 return []byte(fmt.Sprintf("%d,%d", beginning, beginning+length-1))
1004}
1005
1006type ContextDiff UnifiedDiff
1007

Callers 1

WriteContextDiffFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected