Convert range to the "ed" format.
(start, stop int)
| 908 | |
| 909 | // Convert range to the "ed" format. |
| 910 | func 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. |
| 924 | type ContextDiff = LineDiffParams |