MCPcopy Index your code
hub / github.com/go-git/go-git / addLineNumbers

Method addLineNumbers

plumbing/format/diff/unified_encoder.go:257–278  ·  view source on GitHub ↗

addLineNumbers obtains the line numbers in a new chunk.

(la, lb int, linesBefore int, i int, op Operation)

Source from the content-addressed store, hash-verified

255
256// addLineNumbers obtains the line numbers in a new chunk.
257func (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
280func (g *hunksGenerator) processEqualsLines(ls []string, i int) {
281 if g.current == nil {

Callers 1

processHunkMethod · 0.95

Calls 1

TypeMethod · 0.65

Tested by

no test coverage detected