Caching path simplified using fugitive
This commit is contained in:
parent
e0dd3d8125
commit
1ee057362d
@ -15,15 +15,21 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
function! airline#extensions#fugitiveline#bufname()
|
function! airline#extensions#fugitiveline#bufname()
|
||||||
|
if exists('b:fugitive_name')
|
||||||
|
return b:fugitive_name
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:fugitive_name = fnamemodify(bufname('%'), s:fmod)
|
||||||
|
|
||||||
try
|
try
|
||||||
let buffer = fugitive#buffer()
|
let buffer = fugitive#buffer()
|
||||||
if buffer.type('blob')
|
if buffer.type('blob')
|
||||||
return fnamemodify(buffer.repo().translate(buffer.path()), s:fmod)
|
let b:fugitive_name = fnamemodify(buffer.repo().translate(buffer.path()), s:fmod)
|
||||||
endif
|
endif
|
||||||
catch
|
catch
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
return fnamemodify(bufname('%'), s:fmod)
|
return b:fugitive_name
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#fugitiveline#init(ext)
|
function! airline#extensions#fugitiveline#init(ext)
|
||||||
@ -33,5 +39,7 @@ function! airline#extensions#fugitiveline#init(ext)
|
|||||||
else
|
else
|
||||||
call airline#parts#define_raw('file', '%<%{airline#extensions#fugitiveline#bufname()}%m')
|
call airline#parts#define_raw('file', '%<%{airline#extensions#fugitiveline#bufname()}%m')
|
||||||
endif
|
endif
|
||||||
|
autocmd ShellCmdPost,CmdwinLeave * unlet! b:fugitive_name
|
||||||
|
autocmd User AirlineBeforeRefresh unlet! b:fugitive_name
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user