Eliminate b:fugitive_blamed_bufnr
This commit is contained in:
parent
6db7120c9a
commit
9420d05ddd
@ -812,8 +812,9 @@ function! fugitive#Path(url, ...) abort
|
|||||||
return a:1[0:-2] . path
|
return a:1[0:-2] . path
|
||||||
endif
|
endif
|
||||||
let url = a:url
|
let url = a:url
|
||||||
if has_key(get(s:temp_files, s:cpath(url), {}), 'bufnr')
|
let temp_state = s:TempState(url)
|
||||||
let url = bufname(s:temp_files[s:cpath(url)].bufnr)
|
if has_key(temp_state, 'bufnr')
|
||||||
|
let url = bufname(temp_state.bufnr)
|
||||||
endif
|
endif
|
||||||
let url = s:Slash(fnamemodify(url, ':p'))
|
let url = s:Slash(fnamemodify(url, ':p'))
|
||||||
if url =~# '/$' && s:Slash(a:url) !~# '/$'
|
if url =~# '/$' && s:Slash(a:url) !~# '/$'
|
||||||
@ -993,9 +994,9 @@ let s:expand = '\%(\(' . s:var . '\)\(' . s:flag . '*\)\(:S\)\=\)'
|
|||||||
|
|
||||||
function! s:BufName(var) abort
|
function! s:BufName(var) abort
|
||||||
if a:var ==# '%'
|
if a:var ==# '%'
|
||||||
return bufname(get(b:, 'fugitive_blamed_bufnr', ''))
|
return bufname(get(s:TempState(), 'bufnr', ''))
|
||||||
elseif a:var =~# '^#\d*$'
|
elseif a:var =~# '^#\d*$'
|
||||||
let nr = getbufvar(+a:var[1:-1], 'fugitive_blamed_bufnr', '')
|
let nr = get(s:TempState(bufname(+a:var[1:-1])), 'bufnr', '')
|
||||||
return bufname(nr ? nr : +a:var[1:-1])
|
return bufname(nr ? nr : +a:var[1:-1])
|
||||||
else
|
else
|
||||||
return expand(a:var)
|
return expand(a:var)
|
||||||
@ -2066,6 +2067,10 @@ if !exists('s:temp_files')
|
|||||||
let s:temp_files = {}
|
let s:temp_files = {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
function! s:TempState(...) abort
|
||||||
|
return get(s:temp_files, s:cpath(fnamemodify(a:0 ? a:1 : @%, ':p')), {})
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:SetupTemp(file) abort
|
function! s:SetupTemp(file) abort
|
||||||
if has_key(s:temp_files, s:cpath(a:file))
|
if has_key(s:temp_files, s:cpath(a:file))
|
||||||
let dict = s:temp_files[s:cpath(a:file)]
|
let dict = s:temp_files[s:cpath(a:file)]
|
||||||
@ -4551,7 +4556,7 @@ augroup fugitive_blame
|
|||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType fugitiveblame setlocal nomodeline | if len(s:Dir()) | let &l:keywordprg = s:Keywordprg() | endif
|
autocmd FileType fugitiveblame setlocal nomodeline | if len(s:Dir()) | let &l:keywordprg = s:Keywordprg() | endif
|
||||||
autocmd User Fugitive
|
autocmd User Fugitive
|
||||||
\ if get(b:, 'fugitive_type') =~# '^\%(file\|blob\|blame\)$' || filereadable(@%) |
|
\ if get(b:, 'fugitive_type') =~# '^\%(file\|blob\)$' || s:BlameBufnr() > 0 || filereadable(@%) |
|
||||||
\ exe "command! -buffer -bar -bang -range=-1 -nargs=* Gblame :execute s:BlameCommand(<line1>,<line2>,+'<range>',<count>,<bang>0,'<mods>',<q-reg>,<q-args>,[<f-args>])" |
|
\ exe "command! -buffer -bar -bang -range=-1 -nargs=* Gblame :execute s:BlameCommand(<line1>,<line2>,+'<range>',<count>,<bang>0,'<mods>',<q-reg>,<q-args>,[<f-args>])" |
|
||||||
\ endif
|
\ endif
|
||||||
autocmd ColorScheme,GUIEnter * call s:RehighlightBlame()
|
autocmd ColorScheme,GUIEnter * call s:RehighlightBlame()
|
||||||
@ -4569,8 +4574,12 @@ function! s:linechars(pattern) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:BlameBufnr(...) abort
|
function! s:BlameBufnr(...) abort
|
||||||
let val = getbufvar(a:0 ? a:1 : '', 'fugitive_blamed_bufnr')
|
let state = s:TempState(bufname(a:0 ? a:1 : ''))
|
||||||
return val > 0 ? val : -1
|
if get(state, 'filetype', '') ==# 'fugitiveblame'
|
||||||
|
return get(state, 'bufnr', -1)
|
||||||
|
else
|
||||||
|
return -1
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:BlameLeave() abort
|
function! s:BlameLeave() abort
|
||||||
@ -4665,8 +4674,6 @@ function! s:BlameCommand(line1, line2, range, count, bang, mods, reg, arg, args)
|
|||||||
let top = line('w0') + &scrolloff
|
let top = line('w0') + &scrolloff
|
||||||
let current = line('.')
|
let current = line('.')
|
||||||
exe 'keepalt' (a:bang ? 'split' : 'leftabove vsplit') s:fnameescape(temp)
|
exe 'keepalt' (a:bang ? 'split' : 'leftabove vsplit') s:fnameescape(temp)
|
||||||
let b:fugitive_blamed_bufnr = bufnr
|
|
||||||
let b:fugitive_type = 'blame'
|
|
||||||
let w:fugitive_leave = restore
|
let w:fugitive_leave = restore
|
||||||
let b:fugitive_blame_arguments = join(a:args,' ')
|
let b:fugitive_blame_arguments = join(a:args,' ')
|
||||||
execute top
|
execute top
|
||||||
|
Loading…
Reference in New Issue
Block a user