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

Function formatRangeContext

texteditor/difflib/difflib.go:910–921  ·  view source on GitHub ↗

Convert range to the "ed" format.

(start, stop int)

Source from the content-addressed store, hash-verified

908
909// Convert range to the "ed" format.
910func formatRangeContext(start, stop int) string {
911 // Per the diff spec at http://www.unix.org/single_unix_specification/
912 beginning := start + 1 // lines start numbering with one
913 length := stop - start
914 if length == 0 {
915 beginning -= 1 // empty ranges begin at line just before the range
916 }
917 if length <= 1 {
918 return fmt.Sprintf("%d", beginning)
919 }
920 return fmt.Sprintf("%d,%d", beginning, beginning+length-1)
921}
922
923// ContextDiff is for backward compatibility. Ugh.
924type ContextDiff = LineDiffParams

Callers 1

WriteContextDiffFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected