| 278 | } |
| 279 | |
| 280 | func (g *hunksGenerator) processEqualsLines(ls []string, i int) { |
| 281 | if g.current == nil { |
| 282 | g.beforeContext = append(g.beforeContext, ls...) |
| 283 | return |
| 284 | } |
| 285 | |
| 286 | g.afterContext = append(g.afterContext, ls...) |
| 287 | if len(g.afterContext) <= g.ctxLines*2 && i != len(g.chunks)-1 { |
| 288 | g.current.AddOp(Equal, g.afterContext...) |
| 289 | g.afterContext = nil |
| 290 | } else { |
| 291 | ctxLines := g.ctxLines |
| 292 | if ctxLines > len(g.afterContext) { |
| 293 | ctxLines = len(g.afterContext) |
| 294 | } |
| 295 | g.current.AddOp(Equal, g.afterContext[:ctxLines]...) |
| 296 | g.hunks = append(g.hunks, g.current) |
| 297 | |
| 298 | g.current = nil |
| 299 | g.beforeContext = g.afterContext[ctxLines:] |
| 300 | g.afterContext = nil |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | func splitLines(s string) []string { |
| 305 | out := splitLinesRegexp.FindAllString(s, -1) |