diff --git a/powerline/bindings/vim/powerline.vim b/powerline/bindings/vim/powerline.vim index c030596b..9f0499f1 100644 --- a/powerline/bindings/vim/powerline.vim +++ b/powerline/bindings/vim/powerline.vim @@ -23,17 +23,25 @@ function! Powerline(winnr, current) return s:pyeval('powerline.renderer.render('. a:winnr .', '. a:current .')') endfunction -function! s:UpdateWindows() +function! s:UpdateWindows(use_last_current_window_id) if ! exists('w:window_id') let w:window_id = s:pyeval('str(uuid.uuid4())') endif for winnr in range(1, winnr('$')) - call setwinvar(winnr, '&statusline', '%!Powerline('. winnr .', '. (w:window_id == getwinvar(winnr, 'window_id')) .')') + let current = 0 + if w:window_id == getwinvar(winnr, 'window_id') || (a:use_last_current_window_id && getwinvar(winnr, 'window_id') == s:last_current_window_id) + let current = 1 + if bufname(winbufnr(winnr)) isnot# '[Command Line]' + let s:last_current_window_id = getwinvar(winnr, 'window_id') + endif + endif + call setwinvar(winnr, '&statusline', '%!Powerline('. winnr .', '. current .')') endfor - redrawstatus endfunction +let s:last_current_window_id = '' augroup Powerline autocmd! - autocmd BufEnter,BufWinEnter,WinEnter,CmdwinEnter * call s:UpdateWindows() + autocmd BufEnter,BufWinEnter,WinEnter,CmdwinEnter * call s:UpdateWindows(0) | redrawstatus + autocmd CmdwinLeave * call s:UpdateWindows(1) augroup END