From 61d467b573b3dfeebeb6ffd3d7fb7addd9b304c8 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 2 Jan 2019 00:42:22 -0500 Subject: [PATCH] Extract function for reloading individual :Gstatus --- autoload/fugitive.vim | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index bf8ab23..398d1f4 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1533,8 +1533,8 @@ function! fugitive#BufReadStatus() abort nnoremap P :execute StagePatch(line('.'),line('.')+v:count1-1) xnoremap P :execute StagePatch(line("'<"),line("'>")) nnoremap q :if bufnr('$') == 1quitelsebdeleteendif - nnoremap r :edit - nnoremap R :edit + nnoremap r :exe ReloadStatus() + nnoremap R :exe ReloadStatus() nnoremap U :echoerr 'Changed to g' nnoremap g :execute StageUndo() nnoremap . : =fnameescape(StatusCfile()) @@ -1867,6 +1867,13 @@ function! s:Status(bang, count, mods) abort return '' endfunction +function! s:ReloadStatus() abort + let pos = getpos('.') + call fugitive#BufReadStatus() + call setpos('.', pos) + return '' +endfunction + function! fugitive#ReloadStatus(...) abort if exists('s:reloading_status') return @@ -1884,9 +1891,7 @@ function! fugitive#ReloadStatus(...) abort endif try if !&modified - let pos = getpos('.') - call fugitive#BufReadStatus() - call setpos('.', pos) + exe s:ReloadStatus() endif finally if exists('restorewinnr') @@ -1951,7 +1956,7 @@ function! s:StageReloadSeek(target,lnum1,lnum2) abort if empty(target[0]) let target = a:target endif - silent! edit! + call s:ReloadStatus() 1 redraw let lnum = 0