mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-22 15:23:55 +08:00
main: Make :AirlineRefresh! skip recrecrating highlighting groups
When `g:skip_empty_sections` is set, `:AirlineRefresh` can be called very often and cause slow down, because it forcefully re-creates the highlighting groups. This is mostly not needed for the redraw to happen, therefore, add the `<bang>` attribute to the command, making it skip to re-create the highlighting groups and have all extensions that rely on a forced update use the `!` form. Should be much fast then. fixes #1908
This commit is contained in:
parent
fdd75df927
commit
a753422549
|
@ -124,6 +124,6 @@ endfunction
|
||||||
|
|
||||||
function! s:ale_refresh()
|
function! s:ale_refresh()
|
||||||
if get(g:, 'airline_skip_empty_sections', 0)
|
if get(g:, 'airline_skip_empty_sections', 0)
|
||||||
exe ':AirlineRefresh'
|
exe ':AirlineRefresh!'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -22,7 +22,7 @@ let s:diagnostics = {}
|
||||||
|
|
||||||
function! s:languageclient_refresh()
|
function! s:languageclient_refresh()
|
||||||
if get(g:, 'airline_skip_empty_sections', 0)
|
if get(g:, 'airline_skip_empty_sections', 0)
|
||||||
exe ':AirlineRefresh'
|
exe ':AirlineRefresh!'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ function! s:ws_refresh()
|
||||||
endif
|
endif
|
||||||
unlet! b:airline_whitespace_check
|
unlet! b:airline_whitespace_check
|
||||||
if get(g:, 'airline_skip_empty_sections', 0)
|
if get(g:, 'airline_skip_empty_sections', 0)
|
||||||
exe ':AirlineRefresh'
|
exe ':AirlineRefresh!'
|
||||||
endif
|
endif
|
||||||
let b:airline_ws_changedtick = b:changedtick
|
let b:airline_ws_changedtick = b:changedtick
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -257,8 +257,9 @@ COMMANDS *airline-commands*
|
||||||
:AirlineToggle *:AirlineToggle*
|
:AirlineToggle *:AirlineToggle*
|
||||||
Toggles between the standard 'statusline' and airline.
|
Toggles between the standard 'statusline' and airline.
|
||||||
|
|
||||||
:AirlineRefresh *:AirlineRefresh*
|
:AirlineRefresh[!] *:AirlineRefresh*
|
||||||
Refreshes all highlight groups and redraws the statusline.
|
Refreshes all highlight groups and redraws the statusline. With the '!'
|
||||||
|
attribute, skips refreshing the highlighting groups.
|
||||||
|
|
||||||
:AirlineExtensions *:AirlineExtensions*
|
:AirlineExtensions *:AirlineExtensions*
|
||||||
Shows the status of all available airline extensions.
|
Shows the status of all available airline extensions.
|
||||||
|
|
|
@ -195,14 +195,18 @@ function! s:airline_theme(...)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:airline_refresh()
|
function! s:airline_refresh(...)
|
||||||
|
" a:1, fast refresh, do not reload the theme
|
||||||
|
let fast=!empty(get(a:000, 0, 0))
|
||||||
if !exists("#airline")
|
if !exists("#airline")
|
||||||
" disabled
|
" disabled
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call airline#util#doautocmd('AirlineBeforeRefresh')
|
call airline#util#doautocmd('AirlineBeforeRefresh')
|
||||||
call airline#highlighter#reset_hlcache()
|
call airline#highlighter#reset_hlcache()
|
||||||
call airline#load_theme()
|
if !fast
|
||||||
|
call airline#load_theme()
|
||||||
|
endif
|
||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
call airline#update_tabline()
|
call airline#update_tabline()
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -255,7 +259,7 @@ endfunction
|
||||||
command! -bar -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
|
command! -bar -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
|
||||||
command! -bar AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
|
command! -bar AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
|
||||||
command! -bar AirlineToggle call s:airline_toggle()
|
command! -bar AirlineToggle call s:airline_toggle()
|
||||||
command! -bar AirlineRefresh call s:airline_refresh()
|
command! -bar -bang AirlineRefresh call s:airline_refresh(<q-bang>)
|
||||||
command! AirlineExtensions call s:airline_extensions()
|
command! AirlineExtensions call s:airline_extensions()
|
||||||
|
|
||||||
call airline#init#bootstrap()
|
call airline#init#bootstrap()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user