mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 19:43:47 -05:00
Prevent undo-hunk scrolling window.
The previous implementation assumed that CTRL-Y and CTRL-E could scroll by negative counts, i.e. in the opposite direction. It turns out they cannot: they treat negative counts as positive ones and always scroll in the same direction. This meant that undoing a hunk in the top half of the screen caused the screen to scroll. Closes #394.
This commit is contained in:
@@ -209,10 +209,16 @@ function! gitgutter#undo_hunk() abort
|
|||||||
call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' apply --reverse --unidiff-zero - '), diff_for_hunk)
|
call gitgutter#utility#system(gitgutter#utility#command_in_directory_of_file(g:gitgutter_git_executable.' apply --reverse --unidiff-zero - '), diff_for_hunk)
|
||||||
|
|
||||||
" reload file preserving screen line position
|
" reload file preserving screen line position
|
||||||
let wl = winline()
|
" CTRL-Y and CTRL-E treat negative counts as positive counts.
|
||||||
|
let x = line('w0')
|
||||||
silent edit
|
silent edit
|
||||||
let offset = wl - winline()
|
let y = line('w0')
|
||||||
execute "normal! ".offset."\<C-Y>"
|
let z = x - y
|
||||||
|
if z > 0
|
||||||
|
execute "normal! ".z."\<C-E>"
|
||||||
|
else
|
||||||
|
execute "normal! ".z."\<C-Y>"
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
silent! call repeat#set("\<Plug>GitGutterUndoHunk", -1)<CR>
|
silent! call repeat#set("\<Plug>GitGutterUndoHunk", -1)<CR>
|
||||||
|
|||||||
Reference in New Issue
Block a user