Convert range to the "ed" format.
(start, stop int)
| 991 | |
| 992 | // Convert range to the "ed" format. |
| 993 | func 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 | |
| 1006 | type ContextDiff UnifiedDiff |
| 1007 |