From 1ee057362dde1ff93d7f36ea8bc6dc71ccb448e4 Mon Sep 17 00:00:00 2001 From: Cimbali Date: Sat, 23 Dec 2017 15:18:39 +0100 Subject: [PATCH] Caching path simplified using fugitive --- autoload/airline/extensions/fugitiveline.vim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/autoload/airline/extensions/fugitiveline.vim b/autoload/airline/extensions/fugitiveline.vim index e2fcad7..831f931 100644 --- a/autoload/airline/extensions/fugitiveline.vim +++ b/autoload/airline/extensions/fugitiveline.vim @@ -15,15 +15,21 @@ else endif function! airline#extensions#fugitiveline#bufname() + if exists('b:fugitive_name') + return b:fugitive_name + endif + + let b:fugitive_name = fnamemodify(bufname('%'), s:fmod) + try let buffer = fugitive#buffer() 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 catch endtry - return fnamemodify(bufname('%'), s:fmod) + return b:fugitive_name endfunction function! airline#extensions#fugitiveline#init(ext) @@ -33,5 +39,7 @@ function! airline#extensions#fugitiveline#init(ext) else call airline#parts#define_raw('file', '%<%{airline#extensions#fugitiveline#bufname()}%m') endif + autocmd ShellCmdPost,CmdwinLeave * unlet! b:fugitive_name + autocmd User AirlineBeforeRefresh unlet! b:fugitive_name endfunction