Extract function for reloading individual :Gstatus

This commit is contained in:
Tim Pope
2019-01-02 00:42:22 -05:00
parent 054ac50975
commit 61d467b573

View File

@@ -1533,8 +1533,8 @@ function! fugitive#BufReadStatus() abort
nnoremap <buffer> <silent> P :<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR> nnoremap <buffer> <silent> P :<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR>
xnoremap <buffer> <silent> P :<C-U>execute <SID>StagePatch(line("'<"),line("'>"))<CR> xnoremap <buffer> <silent> P :<C-U>execute <SID>StagePatch(line("'<"),line("'>"))<CR>
nnoremap <buffer> <silent> q :<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR> nnoremap <buffer> <silent> q :<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR>
nnoremap <buffer> <silent> r :<C-U>edit<CR> nnoremap <buffer> <silent> r :<C-U>exe <SID>ReloadStatus()<CR>
nnoremap <buffer> <silent> R :<C-U>edit<CR> nnoremap <buffer> <silent> R :<C-U>exe <SID>ReloadStatus()<CR>
nnoremap <buffer> <silent> U :<C-U>echoerr 'Changed to g<Bar>'<CR> nnoremap <buffer> <silent> U :<C-U>echoerr 'Changed to g<Bar>'<CR>
nnoremap <buffer> <silent> g<Bar> :<C-U>execute <SID>StageUndo()<CR> nnoremap <buffer> <silent> g<Bar> :<C-U>execute <SID>StageUndo()<CR>
nnoremap <buffer> . : <C-R>=<SID>fnameescape(<SID>StatusCfile())<CR><Home> nnoremap <buffer> . : <C-R>=<SID>fnameescape(<SID>StatusCfile())<CR><Home>
@@ -1867,6 +1867,13 @@ function! s:Status(bang, count, mods) abort
return '' return ''
endfunction endfunction
function! s:ReloadStatus() abort
let pos = getpos('.')
call fugitive#BufReadStatus()
call setpos('.', pos)
return ''
endfunction
function! fugitive#ReloadStatus(...) abort function! fugitive#ReloadStatus(...) abort
if exists('s:reloading_status') if exists('s:reloading_status')
return return
@@ -1884,9 +1891,7 @@ function! fugitive#ReloadStatus(...) abort
endif endif
try try
if !&modified if !&modified
let pos = getpos('.') exe s:ReloadStatus()
call fugitive#BufReadStatus()
call setpos('.', pos)
endif endif
finally finally
if exists('restorewinnr') if exists('restorewinnr')
@@ -1951,7 +1956,7 @@ function! s:StageReloadSeek(target,lnum1,lnum2) abort
if empty(target[0]) if empty(target[0])
let target = a:target let target = a:target
endif endif
silent! edit! call s:ReloadStatus()
1 1
redraw redraw
let lnum = 0 let lnum = 0