addLineNumbers obtains the line numbers in a new chunk.
(la, lb int, linesBefore int, i int, op Operation)
| 255 | |
| 256 | // addLineNumbers obtains the line numbers in a new chunk. |
| 257 | func (g *hunksGenerator) addLineNumbers(la, lb int, linesBefore int, i int, op Operation) (cla, clb int) { |
| 258 | cla = la - linesBefore |
| 259 | // we need to search for a reference for the next diff |
| 260 | switch { |
| 261 | case linesBefore != 0 && g.ctxLines != 0: |
| 262 | if lb > g.ctxLines { |
| 263 | clb = lb - g.ctxLines + 1 |
| 264 | } else { |
| 265 | clb = 1 |
| 266 | } |
| 267 | case g.ctxLines == 0: |
| 268 | clb = lb |
| 269 | case i != len(g.chunks)-1: |
| 270 | next := g.chunks[i+1] |
| 271 | if next.Type() == op || next.Type() == Equal { |
| 272 | // this diff will be into this chunk |
| 273 | clb = lb + 1 |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | return |
| 278 | } |
| 279 | |
| 280 | func (g *hunksGenerator) processEqualsLines(ls []string, i int) { |
| 281 | if g.current == nil { |