Skip to content

Commit 66bafa5

Browse files
committed
Update open preview on hunk jump
See airblade#396, airblade#779.
1 parent e288dd4 commit 66bafa5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

autoload/gitgutter/hunk.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ function! gitgutter#hunk#next_hunk(count) abort
6464
if g:gitgutter_show_msg_on_hunk_jumping
6565
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
6666
endif
67+
if s:is_preview_window_open()
68+
call gitgutter#hunk#preview()
69+
endif
6770
return
6871
endif
6972
endif
@@ -92,6 +95,9 @@ function! gitgutter#hunk#prev_hunk(count) abort
9295
if g:gitgutter_show_msg_on_hunk_jumping
9396
redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks))
9497
endif
98+
if s:is_preview_window_open()
99+
call gitgutter#hunk#preview()
100+
endif
95101
return
96102
endif
97103
endif
@@ -593,3 +599,14 @@ function! s:close_hunk_preview_window()
593599
let s:winid = 0
594600
let s:preview_bufnr = 0
595601
endfunction
602+
603+
604+
" Only makes sense for traditional, non-floating preview window.
605+
function s:is_preview_window_open()
606+
for i in range(1, winnr('$'))
607+
if getwinvar(i, '&previewwindow') == 1
608+
return 1
609+
endif
610+
endfor
611+
return 0
612+
endfunction

0 commit comments

Comments
 (0)