MCPcopy Create free account
hub / github.com/pmezard/go-difflib / formatRangeContext

Function formatRangeContext

difflib/difflib.go:642–653  ·  view source on GitHub ↗

Convert range to the "ed" format.

(start, stop int)

Source from the content-addressed store, hash-verified

640
641// Convert range to the "ed" format.
642func formatRangeContext(start, stop int) string {
643 // Per the diff spec at http://www.unix.org/single_unix_specification/
644 beginning := start + 1 // lines start numbering with one
645 length := stop - start
646 if length == 0 {
647 beginning -= 1 // empty ranges begin at line just before the range
648 }
649 if length <= 1 {
650 return fmt.Sprintf("%d", beginning)
651 }
652 return fmt.Sprintf("%d,%d", beginning, beginning+length-1)
653}
654
655type ContextDiff UnifiedDiff
656

Callers 1

WriteContextDiffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…