1 2source shared.vim 3 4func TablineWithCaughtError() 5 let s:func_in_tabline_called = 1 6 try 7 call eval('unknown expression') 8 catch 9 endtry 10 return '' 11endfunc 12 13func TablineWithError() 14 let s:func_in_tabline_called = 1 15 call eval('unknown expression') 16 return '' 17endfunc 18 19func Test_caught_error_in_tabline() 20 if has('gui') 21 set guioptions-=e 22 endif 23 let showtabline_save = &showtabline 24 set showtabline=2 25 let s:func_in_tabline_called = 0 26 let tabline = '%{TablineWithCaughtError()}' 27 let &tabline = tabline 28 redraw! 29 call assert_true(s:func_in_tabline_called) 30 call assert_equal(tabline, &tabline) 31 set tabline= 32 let &showtabline = showtabline_save 33endfunc 34 35func Test_tabline_will_be_disabled_with_error() 36 if has('gui') 37 set guioptions-=e 38 endif 39 let showtabline_save = &showtabline 40 set showtabline=2 41 let s:func_in_tabline_called = 0 42 let tabline = '%{TablineWithError()}' 43 try 44 let &tabline = tabline 45 redraw! 46 catch 47 endtry 48 call assert_true(s:func_in_tabline_called) 49 call assert_equal('', &tabline) 50 set tabline= 51 let &showtabline = showtabline_save 52endfunc 53 54func Test_redrawtabline() 55 if has('gui') 56 set guioptions-=e 57 endif 58 let showtabline_save = &showtabline 59 set showtabline=2 60 set tabline=%{bufnr('$')} 61 edit Xtabline1 62 edit Xtabline2 63 redraw 64 call assert_match(bufnr('$') . '', Screenline(1)) 65 au BufAdd * redrawtabline 66 badd Xtabline3 67 call assert_match(bufnr('$') . '', Screenline(1)) 68 69 set tabline= 70 let &showtabline = showtabline_save 71 au! Bufadd 72endfunc 73