Clean up optional arguments around status reload

Best I can tell the ability to pass a line number or tab number argument
has never been used.

Cleaning this up in anticipating of adding actually useful arguments,
and in anticipation of that, I'm preemptively making ReloadWinStatus()
blindly relay any arguments to ReloadStatusBuffer().

References: https://github.com/tpope/vim-fugitive/issues/2207
This commit is contained in:
Tim Pope
2023-09-06 15:29:37 -04:00
parent d4914b361b
commit c7333f63e7

View File

@@ -2671,7 +2671,7 @@ let s:rebase_abbrevs = {
\ 'b': 'break', \ 'b': 'break',
\ } \ }
function! fugitive#BufReadStatus(...) abort function! fugitive#BufReadStatus(cmdbang) abort
let amatch = s:Slash(expand('%:p')) let amatch = s:Slash(expand('%:p'))
unlet! b:fugitive_reltime b:fugitive_type unlet! b:fugitive_reltime b:fugitive_type
try try
@@ -2907,7 +2907,7 @@ function! fugitive#BufReadStatus(...) abort
endif endif
let b:fugitive_diff = diff let b:fugitive_diff = diff
if get(a:, 1, v:cmdbang) if a:cmdbang
unlet! b:fugitive_expanded unlet! b:fugitive_expanded
endif endif
let expanded = get(b:, 'fugitive_expanded', {'Staged': {}, 'Unstaged': {}}) let expanded = get(b:, 'fugitive_expanded', {'Staged': {}, 'Unstaged': {}})
@@ -4282,20 +4282,20 @@ function! s:DoAutocmdChanged(dir) abort
return '' return ''
endfunction endfunction
function! s:ReloadStatusBuffer(...) abort function! s:ReloadStatusBuffer() abort
if get(b:, 'fugitive_type', '') !=# 'index' if get(b:, 'fugitive_type', '') !=# 'index'
return '' return ''
endif endif
let original_lnum = a:0 ? a:1 : line('.') let original_lnum = line('.')
let info = s:StageInfo(original_lnum) let info = s:StageInfo(original_lnum)
exe fugitive#BufReadStatus(0) exe fugitive#BufReadStatus(0)
call setpos('.', [0, s:StageSeek(info, original_lnum), 1, 0]) call setpos('.', [0, s:StageSeek(info, original_lnum), 1, 0])
return '' return ''
endfunction endfunction
function! s:ReloadStatus(...) abort function! s:ReloadStatus() abort
call s:ExpireStatus(-1) call s:ExpireStatus(-1)
call s:ReloadStatusBuffer(a:0 ? a:1 : line('.')) call s:ReloadStatusBuffer()
exe s:DoAutocmdChanged(-1) exe s:DoAutocmdChanged(-1)
return '' return ''
endfunction endfunction
@@ -4326,23 +4326,20 @@ function! s:ReloadWinStatus(...) abort
return return
endif endif
if !exists('b:fugitive_reltime') if !exists('b:fugitive_reltime')
exe s:ReloadStatusBuffer() exe call('s:ReloadStatusBuffer', a:000)
return return
endif endif
let t = b:fugitive_reltime let t = b:fugitive_reltime
if reltimestr(reltime(s:last_time, t)) =~# '-\|\d\{10\}\.' || if reltimestr(reltime(s:last_time, t)) =~# '-\|\d\{10\}\.' ||
\ reltimestr(reltime(get(s:last_times, s:Tree() . '/', t), t)) =~# '-\|\d\{10\}\.' \ reltimestr(reltime(get(s:last_times, s:Tree() . '/', t), t)) =~# '-\|\d\{10\}\.'
exe s:ReloadStatusBuffer() exe call('s:ReloadStatusBuffer', a:000)
endif endif
endfunction endfunction
function! s:ReloadTabStatus(...) abort function! s:ReloadTabStatus() abort
let mytab = tabpagenr()
let tab = a:0 ? a:1 : mytab
let winnr = 1 let winnr = 1
while winnr <= tabpagewinnr(tab, '$') while winnr <= winnr('$')
if getbufvar(tabpagebuflist(tab)[winnr-1], 'fugitive_type') ==# 'index' if getbufvar(winbufnr(winnr), 'fugitive_type') ==# 'index'
execute 'tabnext '.tab
if winnr != winnr() if winnr != winnr()
execute winnr.'wincmd w' execute winnr.'wincmd w'
let restorewinnr = 1 let restorewinnr = 1
@@ -4354,7 +4351,6 @@ function! s:ReloadTabStatus(...) abort
unlet restorewinnr unlet restorewinnr
wincmd p wincmd p
endif endif
execute 'tabnext '.mytab
endtry endtry
endif endif
let winnr += 1 let winnr += 1