From c869665b1648b3e596606975323514ab75d1fb98 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Wed, 25 Sep 2013 00:25:20 -0400 Subject: [PATCH] guard against attempting to load invalid themes. --- autoload/airline.vim | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 501e537e..23736682 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -31,8 +31,18 @@ function! airline#load_theme() endfunction function! airline#switch_theme(name) - let g:airline_theme = a:name - let palette = g:airline#themes#{g:airline_theme}#palette "also lazy loads the theme + try + let palette = g:airline#themes#{a:name}#palette "also lazy loads the theme + let g:airline_theme = a:name + catch + echohl WarningMsg | echo 'The specified theme cannot be found.' | echohl NONE + if exists('g:airline_theme') + return + else + let g:airline_theme = 'dark' + let palette = g:airline#themes#dark#palette + endif + endtry call airline#themes#patch(palette) if exists('g:airline_theme_patch_func')