From 63941de9f9ac2d8d5281b521be1dcce4e5c41739 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Tue, 28 Jul 2020 10:12:48 +0100 Subject: [PATCH] Distinguish no hunks at all from no further hunks Closes #709. --- autoload/gitgutter/hunk.vim | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index 2c9aa05..2542524 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -47,9 +47,14 @@ endfunction function! gitgutter#hunk#next_hunk(count) abort let bufnr = bufnr('') if gitgutter#utility#is_active(bufnr) + let hunks = gitgutter#hunk#hunks(bufnr) + if empty(hunks) + call gitgutter#utility#warn('No hunks in file') + return + endif let current_line = line('.') let hunk_count = 0 - for hunk in gitgutter#hunk#hunks(bufnr) + for hunk in hunks if hunk[2] > current_line let hunk_count += 1 if hunk_count == a:count @@ -65,9 +70,14 @@ endfunction function! gitgutter#hunk#prev_hunk(count) abort let bufnr = bufnr('') if gitgutter#utility#is_active(bufnr) + let hunks = gitgutter#hunk#hunks(bufnr) + if empty(hunks) + call gitgutter#utility#warn('No hunks in file') + return + endif let current_line = line('.') let hunk_count = 0 - for hunk in reverse(copy(gitgutter#hunk#hunks(bufnr))) + for hunk in reverse(copy(hunks)) if hunk[2] < current_line let hunk_count += 1 if hunk_count == a:count