(newBodyLines []*PatchLine, oldStart int, startOffset int)
| 205 | } |
| 206 | |
| 207 | func (self *patchTransformer) transformHunkHeader(newBodyLines []*PatchLine, oldStart int, startOffset int) (int, int) { |
| 208 | oldLength := nLinesWithKind(newBodyLines, []PatchLineKind{CONTEXT, DELETION}) |
| 209 | newLength := nLinesWithKind(newBodyLines, []PatchLineKind{CONTEXT, ADDITION}) |
| 210 | |
| 211 | var newStartOffset int |
| 212 | // if the hunk went from zero to positive length, we need to increment the starting point by one |
| 213 | // if the hunk went from positive to zero length, we need to decrement the starting point by one |
| 214 | if oldLength == 0 { |
| 215 | newStartOffset = 1 |
| 216 | } else if newLength == 0 { |
| 217 | newStartOffset = -1 |
| 218 | } else { |
| 219 | newStartOffset = 0 |
| 220 | } |
| 221 | |
| 222 | newStart := oldStart + startOffset + newStartOffset |
| 223 | |
| 224 | newStartOffset = startOffset + newLength - oldLength |
| 225 | |
| 226 | return newStart, newStartOffset |
| 227 | } |
no test coverage detected