Don't disrupt the statusline if ctags fails

This commit is contained in:
Jan Larres 2013-03-23 19:46:14 +13:00
parent c1c7d962af
commit 77a318b10e
2 changed files with 22 additions and 7 deletions

View File

@ -1714,6 +1714,14 @@ function! s:OpenWindow(flags) abort
call s:InitWindow(autoclose)
" If the current file exists, but is empty, it means that it had a
" processing error before opening the window, most likely due to a call to
" currenttag() in the statusline. Remove the entry so an error message
" will be shown if the processing still fails.
if empty(s:known_files.get(curfile))
call s:known_files.rm(curfile)
endif
call s:AutoUpdate(curfile, 0)
call s:HighlightTag(1, 1, curline)
@ -2062,8 +2070,11 @@ function! s:ExecuteCtagsOnFile(fname, realfname, ftype) abort
let ctags_output = s:ExecuteCtags(ctags_cmd)
if v:shell_error || ctags_output =~ 'Warning: cannot open source file'
if !s:known_files.has(a:realfname) ||
\ !empty(s:known_files.get(a:realfname))
" Only display an error message if the Tagbar window is open and we
" haven't seen the error before.
if bufwinnr("__Tagbar__") != -1 &&
\ (!s:known_files.has(a:realfname) ||
\ !empty(s:known_files.get(a:realfname)))
echoerr 'Tagbar: Could not execute ctags for ' . a:fname . '!'
echomsg 'Executed command: "' . ctags_cmd . '"'
if !empty(ctags_output)

View File

@ -635,7 +635,8 @@ you want to, by calling the tagbar#currenttag() function. The current tag is
exactly the same as would be highlighted in the Tagbar window if it is open.
It is defined as the nearest tag upwards in the file starting from the cursor
position. This means that for example in a function it should usually be the
name of the function.
name of the function. You can define which tags will be shown in this manner,
read |tagbar-extend| (especially the "kinds" entry) on how to do that.
The function has the following signature:
@ -658,6 +659,10 @@ tagbar#currenttag({format}, {default} [, {flags}])
%{tagbar#currenttag('[%s] ','')}
< then the function "myfunc" will be shown as "[myfunc()] ".
Note that if there is an error when processing the current file no error
message will be shown in order to not disrupt the statusline. If the function
doesn't seem to work right open the Tagbar window to see any error messages.
==============================================================================
6. Extending Tagbar *tagbar-extend*
@ -687,10 +692,9 @@ support package for the language. Some tips on how to write such a program are
given at the end of this section.
Before writing your own extension have a look at the wiki
(https://github.com/majutsushi/tagbar/wiki/Support-for-additional-filetypes)
or try googling for existing ones. If you do end up creating your own
extension please consider adding it to the wiki so that others will be able to
use it, too.
(https://github.com/majutsushi/tagbar/wiki) or try googling for existing ones.
If you do end up creating your own extension please consider adding it to the
wiki so that others can benefit from it, too.
Every type definition in Tagbar is a dictionary with the following keys: