diff options
Diffstat (limited to 'pkg/gui/patch_exploring')
-rw-r--r-- | pkg/gui/patch_exploring/state.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pkg/gui/patch_exploring/state.go b/pkg/gui/patch_exploring/state.go index 356bff4f4..1c82d59cb 100644 --- a/pkg/gui/patch_exploring/state.go +++ b/pkg/gui/patch_exploring/state.go @@ -143,8 +143,13 @@ func (s *State) CycleHunk(forward bool) { } hunkIdx := s.patch.HunkContainingLine(s.selectedLineIdx) - start := s.patch.HunkStartIdx(hunkIdx + change) - s.selectedLineIdx = s.patch.GetNextChangeIdx(start) + if hunkIdx != -1 { + newHunkIdx := hunkIdx + change + if newHunkIdx >= 0 && newHunkIdx < s.patch.HunkCount() { + start := s.patch.HunkStartIdx(newHunkIdx) + s.selectedLineIdx = s.patch.GetNextChangeIdx(start) + } + } } func (s *State) CycleLine(forward bool) { |