po: only reset cache if window width changed

This commit is contained in:
Christian Brabandt 2018-11-01 11:18:04 +01:00
parent fc021cf4e8
commit 6516b1b4dc
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
1 changed files with 11 additions and 1 deletions

View File

@ -33,11 +33,21 @@ function! airline#extensions#po#shorten()
let b:airline_po_stats = '['.b:airline_po_stats. ']'
endfunction
function! airline#extensions#po#on_winenter()
" only reset cache, if the window size changed
if get(b:, 'airline_winwidth', 0) != winwidth(0)
let b:airline_winwidth = winwidth(0)
" needs re-formatting
unlet! b:airline_po_stats
endif
endfunction
function! airline#extensions#po#apply(...)
if &ft ==# 'po'
call airline#extensions#prepend_to_section('z', '%{airline#extensions#po#stats()}')
" Also reset the cache variable, if a window has been split, e.g. the winwidth changed
autocmd airline BufWritePost,WinEnter * unlet! b:airline_po_stats
autocmd airline BufWritePost * unlet! b:airline_po_stats
autocmd airline WinEnter * call airline#extensions#po#on_winenter()
endif
endfunction