}
diffLine := &DiffLine{Type: DiffLineAdd, RightIdx: rightLine}
rightLine++
+ if curSection == nil {
+ // Create a new section to represent this hunk
+ curSection = &DiffSection{}
+ curFile.Sections = append(curFile.Sections, curSection)
+ }
curSection.Lines = append(curSection.Lines, diffLine)
case '-':
curFileLinesCount++
if leftLine > 0 {
leftLine++
}
+ if curSection == nil {
+ // Create a new section to represent this hunk
+ curSection = &DiffSection{}
+ curFile.Sections = append(curFile.Sections, curSection)
+ }
curSection.Lines = append(curSection.Lines, diffLine)
case ' ':
curFileLinesCount++
diffLine := &DiffLine{Type: DiffLinePlain, LeftIdx: leftLine, RightIdx: rightLine}
leftLine++
rightLine++
+ if curSection == nil {
+ // Create a new section to represent this hunk
+ curSection = &DiffSection{}
+ curFile.Sections = append(curFile.Sections, curSection)
+ }
curSection.Lines = append(curSection.Lines, diffLine)
default:
// This is unexpected