From 1845c5ed30c90524582905a0765ee6e81154556b Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 3 Jul 2013 22:41:02 +0900 Subject: [PATCH] Avoid heavy execution of highlight command --- plugin/airline.vim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugin/airline.vim b/plugin/airline.vim index 10cce05..96016fd 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -121,18 +121,23 @@ function! s:update_statusline(active) call setwinvar(winnr(), '&statusline', sl) endfunction +let s:lastmode = '' + function! AirlineModePrefix() if !&lazyredraw redrawstatus endif let l:mode = mode() - call highlight('normal', ['statusline','statusline_nc','inactive','mode','mode_separator','info','info_separator','file']) + if s:lastmode != l:mode + call highlight('normal', ['statusline','statusline_nc','inactive','mode','mode_separator','info','info_separator','file']) - if l:mode ==# "i" || l:mode ==# "R" - call highlight('insert', ['statusline','mode','mode_separator','info','info_separator']) - elseif l:mode ==? "v" || l:mode ==# "" - call highlight('visual', ['statusline','mode','mode_separator','info','info_separator']) + if l:mode ==# "i" || l:mode ==# "R" + call highlight('insert', ['statusline','mode','mode_separator','info','info_separator']) + elseif l:mode ==? "v" || l:mode ==# "" + call highlight('visual', ['statusline','mode','mode_separator','info','info_separator']) + endif + let s:lastmode = l:mode endif if has_key(s:airline_mode_map, l:mode)