Update open preview on hunk jump

See #396, #779.
This commit is contained in:
Andy Stewart
2021-04-22 15:42:45 +01:00
parent e288dd4733
commit 66bafa5348

View File

@@ -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