[[B]Commits] Preserve window view (#1289)

In 161da95, [B]Commits were changed to range commands with -range=%, now
Vim jumps to the first line when these two commands are called directly
without specifying range.

This fixes it by saving window view in a temporary variable and
restoring it later. Reference: [1].

[1] https://vi.stackexchange.com/a/6037/33583
This commit is contained in:
Frederick Zhang
2021-05-25 14:30:41 +10:00
committed by GitHub
parent 161da95640
commit e34f6c129d
2 changed files with 10 additions and 2 deletions

View File

@@ -1267,10 +1267,18 @@ function! s:given_range(line1, line2)
endfunction
function! fzf#vim#commits(...) range
if exists('b:fzf_winview')
call winrestview(b:fzf_winview)
unlet b:fzf_winview
endif
return s:commits(s:given_range(a:firstline, a:lastline), 0, a:000)
endfunction
function! fzf#vim#buffer_commits(...) range
if exists('b:fzf_winview')
call winrestview(b:fzf_winview)
unlet b:fzf_winview
endif
return s:commits(s:given_range(a:firstline, a:lastline), 1, a:000)
endfunction