From 583121bbc9ed8b1142c14a938bca4a652c4dcfa9 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Mon, 20 Feb 2017 20:24:43 +0100 Subject: [PATCH] before trying to return hi attributes, check the group exists This prevents trying to access twice the highlighting groups and should slightly speed up airline. --- autoload/airline/highlighter.vim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 5cbf590..a38d93a 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -22,12 +22,17 @@ function! s:get_syn(group, what) if !exists("g:airline_gui_mode") let g:airline_gui_mode = airline#init#gui_mode() endif - let color = synIDattr(synIDtrans(hlID(a:group)), a:what, g:airline_gui_mode) - if empty(color) || color == -1 - let color = synIDattr(synIDtrans(hlID('Normal')), a:what, g:airline_gui_mode) + let color = '' + if hlexists(a:group) + let color = synIDattr(synIDtrans(hlID(a:group)), a:what, g:airline_gui_mode) endif if empty(color) || color == -1 - let color = 'NONE' + " should always exists + let color = synIDattr(synIDtrans(hlID('Normal')), a:what, g:airline_gui_mode) + " however, just in case + if empty(color) || color == -1 + let color = 'NONE' + endif endif return color endfunction