(lines []*diffLineData, hunkStartIndex int, currentFile string)
| 205 | } |
| 206 | |
| 207 | func (fancyDiffProcessor *fancyDiffProcessor) processHunkStart(lines []*diffLineData, hunkStartIndex int, currentFile string) (generatedLines []*diffLineData, err error) { |
| 208 | hunkLine := lines[hunkStartIndex] |
| 209 | matches := hunkStartRegex.FindStringSubmatch(hunkLine.line) |
| 210 | if len(matches) != 5 { |
| 211 | err = fmt.Errorf("Hunk start line didn't match expected format, matches: %v", matches) |
| 212 | return |
| 213 | } |
| 214 | |
| 215 | hunkStartLineNumber, err := strconv.Atoi(matches[3]) |
| 216 | if err != nil { |
| 217 | err = fmt.Errorf("Failed to parse hunk start line number %v: %v", matches[3], err) |
| 218 | return |
| 219 | } |
| 220 | |
| 221 | var index int |
| 222 | for index = hunkStartIndex + 1; index < len(lines); index++ { |
| 223 | if lines[index].lineType == dltLineAdded || lines[index].lineType == dltLineRemoved { |
| 224 | break |
| 225 | } |
| 226 | |
| 227 | hunkStartLineNumber++ |
| 228 | } |
| 229 | |
| 230 | if index >= len(lines) { |
| 231 | err = fmt.Errorf("Failed to find changes in hunk") |
| 232 | return |
| 233 | } |
| 234 | |
| 235 | hunkStartLineNumber = MaxInt(hunkStartLineNumber, 1) |
| 236 | |
| 237 | hunkParts := strings.Split(hunkLine.line, " @@") |
| 238 | if len(hunkParts) != 2 { |
| 239 | err = fmt.Errorf("Expected 2 hunk parts but got: %v", hunkParts) |
| 240 | return |
| 241 | } |
| 242 | |
| 243 | sections := []*diffLineSection{ |
| 244 | &diffLineSection{ |
| 245 | text: fmt.Sprintf("@ %v:%v @", currentFile, hunkStartLineNumber), |
| 246 | themeComponentID: CmpDiffviewDifflineHunkStart, |
| 247 | }, |
| 248 | &diffLineSection{ |
| 249 | text: hunkParts[1], |
| 250 | themeComponentID: CmpDiffviewDifflineHunkHeader, |
| 251 | }, |
| 252 | } |
| 253 | |
| 254 | generatedLines = append(generatedLines, newSectionedDiffLineData(sections, dltHunkStart)) |
| 255 | |
| 256 | return |
| 257 | } |
| 258 | |
| 259 | func (fancyDiffProcessor *fancyDiffProcessor) highlightChanges(lines []*diffLineData) { |
| 260 | for lineIndex := 0; lineIndex < len(lines); lineIndex++ { |
no test coverage detected