From 6516b1b4dccef543d489177431050fe8a5c5c99c Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Thu, 1 Nov 2018 11:18:04 +0100 Subject: [PATCH] po: only reset cache if window width changed --- autoload/airline/extensions/po.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/po.vim b/autoload/airline/extensions/po.vim index c027faa..3ec2942 100644 --- a/autoload/airline/extensions/po.vim +++ b/autoload/airline/extensions/po.vim @@ -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