FindNextDiffLine returns the line number of the next block of diffs. If `startLine` is already in a block of diffs, lines in that block are skipped.
(startLine int, forward bool)
| 1424 | // FindNextDiffLine returns the line number of the next block of diffs. |
| 1425 | // If `startLine` is already in a block of diffs, lines in that block are skipped. |
| 1426 | func (b *Buffer) FindNextDiffLine(startLine int, forward bool) (int, error) { |
| 1427 | if b.diff == nil { |
| 1428 | return 0, errors.New("no diff data") |
| 1429 | } |
| 1430 | startStatus, ok := b.diff[startLine] |
| 1431 | if !ok { |
| 1432 | startStatus = DSUnchanged |
| 1433 | } |
| 1434 | curLine := startLine |
| 1435 | for { |
| 1436 | curStatus, ok := b.diff[curLine] |
| 1437 | if !ok { |
| 1438 | curStatus = DSUnchanged |
| 1439 | } |
| 1440 | if curLine < 0 || curLine > b.LinesNum() { |
| 1441 | return 0, errors.New("no next diff hunk") |
| 1442 | } |
| 1443 | if curStatus != startStatus { |
| 1444 | if startStatus != DSUnchanged && curStatus == DSUnchanged { |
| 1445 | // Skip over the block of unchanged text |
| 1446 | startStatus = DSUnchanged |
| 1447 | } else { |
| 1448 | return curLine, nil |
| 1449 | } |
| 1450 | } |
| 1451 | if forward { |
| 1452 | curLine++ |
| 1453 | } else { |
| 1454 | curLine-- |
| 1455 | } |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | // SearchMatch returns true if the given location is within a match of the last search. |
| 1460 | // It is used for search highlighting |
no test coverage detected