diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index 4fd0613..2d601aa 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -64,6 +64,9 @@ function! gitgutter#hunk#next_hunk(count) abort if g:gitgutter_show_msg_on_hunk_jumping redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks)) endif + if s:is_preview_window_open() + call gitgutter#hunk#preview() + endif return endif endif @@ -92,6 +95,9 @@ function! gitgutter#hunk#prev_hunk(count) abort if g:gitgutter_show_msg_on_hunk_jumping redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks)) endif + if s:is_preview_window_open() + call gitgutter#hunk#preview() + endif return endif endif @@ -593,3 +599,14 @@ function! s:close_hunk_preview_window() let s:winid = 0 let s:preview_bufnr = 0 endfunction + + +" Only makes sense for traditional, non-floating preview window. +function s:is_preview_window_open() + for i in range(1, winnr('$')) + if getwinvar(i, '&previewwindow') == 1 + return 1 + endif + endfor + return 0 +endfunction