Tag list not updated when opening unsupported file type
When I open an unsupported file type, the tag list keeps showing the tags from the previous file, instead of clearing the list. Is this the expected behavior?
my vimrc:
set runtimepath+=~/.vim/plugged/tagbar " tagbar @959f487
filetype plugin on
map ,t :TagbarToggle<cr>
map bn :bnext<cr>
Steps to reproduce:
-
$ vim -N -u vimrc -
:e foo.rb(supported file type) - tag list for the file is shown -
:e bar.txt(unsupported file type) - tag list forfoo.rbis still shown
Log from tagbardebug.log
2017-04-25 11:57:19.213215: ToggleWindow called
2017-04-25 11:57:19.213950: OpenWindow called with flags: ''
2017-04-25 11:57:19.215213: Checking for Exuberant Ctags
2017-04-25 11:57:19.215798: EscapeCtagsCmd called
2017-04-25 11:57:19.215937: ctags_bin: /usr/local/bin/ctags
2017-04-25 11:57:19.216064: ctags_args (is a string): --version
2017-04-25 11:57:19.216282: Escaped ctags command: '/usr/local/bin/ctags' --version
2017-04-25 11:57:19.216415: Executing ctags command: '/usr/local/bin/ctags' --version
2017-04-25 11:57:19.230980: Calling shell to execute: "('/usr/local/bin/ctags' --version) >/var/folders/rf/v_6t31n518v_m50tv6sth_yc0000gn/T/v3biGan/1 2>&1"
2017-04-25 11:57:19.231121: Exit code: 0
2017-04-25 11:57:19.232111: Command output:
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Sep 13 2016, 04:58:37
Addresses: <[email protected]>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
2017-04-25 11:57:19.232240: Exit code: 0
2017-04-25 11:57:19.232387: Checking Exuberant Ctags version
2017-04-25 11:57:19.232525: Ctags version: major='5', minor='8'
2017-04-25 11:57:19.232651: Getting filetypes supported by Exuberant Ctags
2017-04-25 11:57:19.232723: EscapeCtagsCmd called
2017-04-25 11:57:19.232824: ctags_bin: /usr/local/bin/ctags
2017-04-25 11:57:19.232916: ctags_args (is a string): --list-languages
2017-04-25 11:57:19.233075: Escaped ctags command: '/usr/local/bin/ctags' --list-languages
2017-04-25 11:57:19.233177: Executing ctags command: '/usr/local/bin/ctags' --list-languages
2017-04-25 11:57:19.257684: Calling shell to execute: "('/usr/local/bin/ctags' --list-languages) >/var/folders/rf/v_6t31n518v_m50tv6sth_yc0000gn/T/v3biGan/2 2>&1"
2017-04-25 11:57:19.257946: Exit code: 0
2017-04-25 11:57:19.260223: Initializing types
2017-04-25 11:57:19.266876: Initializing user types
2017-04-25 11:57:19.269603: Creating autocommands
2017-04-25 11:57:19.271087: AutoUpdate called [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.271594: Vim filetype: 'ruby', sanitized filetype: 'ruby'
2017-04-25 11:57:19.272271: Checking if file is valid [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.273179: New file, processing [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.273636: ProcessFile called [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.274045: Checking if file is valid [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.274790: typeinfo for file to process: {'ctagstype': 'ruby', 'ftype': 'ruby', 'kinddict': {'c': 1, 'F': 3, 'f': 2, 'm': 0, '?': 4}, 'sro': '.', 'getKind': function('34'), 'createKinddict': function('35'), 'kind2scope': {'c': 'class', 'f': 'class', 'm': 'class', '?': 'unknown'}, 'scope2kind': {'class': 'c'}, 'New': function('33'), 'kinds': [{'short': 'm', 'long': 'modules', 'fold': 0, 'stl': 1}, {'short': 'c', 'long': 'classes', 'fold': 0, 'stl': 1}, {'short': 'f', 'long': 'methods', 'fold': 0, 'stl': 1}, {'short': 'F', 'long': 'singleton methods', 'fold': 0, 'stl': 1}, {'short': '?', 'long': 'unknown', 'fold': 0, 'stl': 1}]}
2017-04-25 11:57:19.275599: ExecuteCtagsOnFile called [/var/folders/rf/v_6t31n518v_m50tv6sth_yc0000gn/T/v3biGan/3.rb]
2017-04-25 11:57:19.275946: EscapeCtagsCmd called
2017-04-25 11:57:19.276115: ctags_bin: /usr/local/bin/ctags
2017-04-25 11:57:19.276290: ctags_args (is a list): ['-f', '-', '--format=2', '--excmd=pattern', '--fields=nksSaf', '--extra=', '--file-scope=yes', '--sort=no', '--append=no', '--language-force=ruby', '--ruby-kinds=mcfF']
2017-04-25 11:57:19.276590: Escaped ctags command: '/usr/local/bin/ctags' '-f' '-' '--format=2' '--excmd=pattern' '--fields=nksSaf' '--extra=' '--file-scope=yes' '--sort=no' '--append=no' '--language-force=ruby' '--ruby-kinds=mcfF' '/var/folders/rf/v_6t31n518v_m50tv6sth_yc0000gn/T/v3biGan/3.rb'
2017-04-25 11:57:19.276782: Executing ctags command: '/usr/local/bin/ctags' '-f' '-' '--format=2' '--excmd=pattern' '--fields=nksSaf' '--extra=' '--file-scope=yes' '--sort=no' '--append=no' '--language-force=ruby' '--ruby-kinds=mcfF' '/var/folders/rf/v_6t31n518v_m50tv6sth_yc0000gn/T/v3biGan/3.rb'
2017-04-25 11:57:19.295830: Calling shell to execute: "('/usr/local/bin/ctags' '-f' '-' '--format=2' '--excmd=pattern' '--fields=nksSaf' '--extra=' '--file-scope=yes' '--sort=no' '--append=no' '--language-force=ruby' '--ruby-kinds=mcfF' '/var/folders/rf/v_6t31n518v_m50tv6sth_yc0000gn/T/v3biGan/3.rb') >/var/folders/rf/v_6t31n518v_m50tv6sth_yc0000gn/T/v3biGan/4 2>&1"
2017-04-25 11:57:19.296058: Exit code: 0
2017-04-25 11:57:19.296903: Ctags executed successfully
2017-04-25 11:57:19.297345: Filetype tag kinds: ['c', 'F', 'f', 'm', '?']
2017-04-25 11:57:19.297466: Parsing ctags output
2017-04-25 11:57:19.298508: Processing kind: F, number of tags: 0
2017-04-25 11:57:19.298855: Setting current file [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.299281: AutoUpdate finished successfully
2017-04-25 11:57:19.302668: AutoUpdate called [/Users/random/Desktop/__Tagbar__.1]
2017-04-25 11:57:19.302799: Still opening window, stopping processing
2017-04-25 11:57:19.302926: InitWindow called with autoclose: 0
2017-04-25 11:57:19.303348: AutoUpdate called [/Users/random/Desktop/__Tagbar__.1]
2017-04-25 11:57:19.303479: In Tagbar window, stopping processing
2017-04-25 11:57:19.304124: Mapping keys
2017-04-25 11:57:19.304936: InitWindow finished
2017-04-25 11:57:19.305049: AutoUpdate called [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.305177: Vim filetype: 'ruby', sanitized filetype: 'ruby'
2017-04-25 11:57:19.305268: Checking if file is valid [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.305467: File data seems up to date [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.305624: RenderContent called
2017-04-25 11:57:19.305788: Redisplaying file [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.306031: PrintKinds called
2017-04-25 11:57:19.306196: Printing kind: m, number of (top-level) tags: 0
2017-04-25 11:57:19.309505: Printing kind: c, number of (top-level) tags: 0
2017-04-25 11:57:19.309880: Printing kind: f, number of (top-level) tags: 1
2017-04-25 11:57:19.310316: Printing kind: F, number of (top-level) tags: 0
2017-04-25 11:57:19.310480: Printing kind: ?, number of (top-level) tags: 0
2017-04-25 11:57:19.310883: Setting current file [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.311165: Highlight pattern: '/^\%3l\s*[▼▶ ][-+# ]\zs[^( ]\+\ze/'
2017-04-25 11:57:19.311659: AutoUpdate finished successfully
2017-04-25 11:57:19.312011: RenderContent called
2017-04-25 11:57:19.312190: Redisplaying file [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.312399: PrintKinds called
2017-04-25 11:57:19.312496: Printing kind: m, number of (top-level) tags: 0
2017-04-25 11:57:19.312588: Printing kind: c, number of (top-level) tags: 0
2017-04-25 11:57:19.312668: Printing kind: f, number of (top-level) tags: 1
2017-04-25 11:57:19.312980: Printing kind: F, number of (top-level) tags: 0
2017-04-25 11:57:19.313079: Printing kind: ?, number of (top-level) tags: 0
2017-04-25 11:57:19.313501: Highlight pattern: '/^\%3l\s*[▼▶ ][-+# ]\zs[^( ]\+\ze/'
2017-04-25 11:57:19.314277: AutoUpdate called [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.314416: Vim filetype: 'ruby', sanitized filetype: 'ruby'
2017-04-25 11:57:19.314492: Checking if file is valid [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.314753: File data seems up to date [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.314939: Setting current file [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:19.315143: goto_win(): wincmd p, 1
2017-04-25 11:57:19.315242: goto_win(): 2wincmd w, 1
2017-04-25 11:57:19.315406: goto_win(): 2wincmd w, 1
2017-04-25 11:57:19.315510: goto_win(): 1wincmd w, 1
2017-04-25 11:57:19.315592: AutoUpdate finished successfully
2017-04-25 11:57:19.315676: OpenWindow finished
2017-04-25 11:57:19.315746: ToggleWindow finished
2017-04-25 11:57:25.289066: AutoUpdate called [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:25.289395: Vim filetype: 'ruby', sanitized filetype: 'ruby'
2017-04-25 11:57:25.290597: Checking if file is valid [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:25.290985: File data seems up to date [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:25.291305: Setting current file [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:25.291818: goto_win(): wincmd p, 1
2017-04-25 11:57:25.292030: goto_win(): 2wincmd w, 1
2017-04-25 11:57:25.292353: goto_win(): 2wincmd w, 1
2017-04-25 11:57:25.292524: goto_win(): 1wincmd w, 1
2017-04-25 11:57:25.292674: AutoUpdate finished successfully
2017-04-25 11:57:26.226147: AutoUpdate called [/Users/random/Desktop/__Tagbar__.1]
2017-04-25 11:57:26.226461: In Tagbar window, stopping processing
2017-04-25 11:57:27.185998: AutoUpdate called [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:27.186276: Vim filetype: 'ruby', sanitized filetype: 'ruby'
2017-04-25 11:57:27.187432: Checking if file is valid [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:27.187822: File data seems up to date [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:27.188123: Setting current file [/Users/random/Desktop/foo.rb]
2017-04-25 11:57:27.188516: goto_win(): wincmd p, 1
2017-04-25 11:57:27.188726: goto_win(): 2wincmd w, 1
2017-04-25 11:57:27.189048: goto_win(): 2wincmd w, 1
2017-04-25 11:57:27.189221: goto_win(): 1wincmd w, 1
2017-04-25 11:57:27.189331: AutoUpdate finished successfully
2017-04-25 11:57:32.444471: AutoUpdate called [/Users/random/Desktop/bar.txt]
2017-04-25 11:57:32.444655: Vim filetype: 'text', sanitized filetype: 'text'
2017-04-25 11:57:32.445934: Checking if file is valid [/Users/random/Desktop/bar.txt]
2017-04-25 11:57:32.446119: Unsupported filetype: text
2017-04-25 11:57:32.446201: Not a valid file, stopping processing
2017-04-25 11:57:32.446443: AutoUpdate called [/Users/random/Desktop/bar.txt]
2017-04-25 11:57:32.446590: Vim filetype: 'text', sanitized filetype: 'text'
2017-04-25 11:57:32.446673: Checking if file is valid [/Users/random/Desktop/bar.txt]
2017-04-25 11:57:32.446870: Unsupported filetype: text
2017-04-25 11:57:32.446947: Not a valid file, stopping processing
2017-04-25 11:57:32.447193: AutoUpdate called [/Users/random/Desktop/bar.txt]
2017-04-25 11:57:32.447320: Vim filetype: 'text', sanitized filetype: 'text'
2017-04-25 11:57:32.447398: Checking if file is valid [/Users/random/Desktop/bar.txt]
2017-04-25 11:57:32.447538: Unsupported filetype: text
2017-04-25 11:57:32.447611: Not a valid file, stopping processing
2017-04-25 11:57:34.271954: goto_win(): 1wincmd w, 1
Log from tagbardebug.log.ctags_out
foo /var/folders/rf/v_6t31n518v_m50tv6sth_yc0000gn/T/v3biGan/3.rb /^def foo$/;" f line:1
It seems s:RenderContent is not called at all for unsupported file type (https://github.com/majutsushi/tagbar/blob/master/autoload/tagbar.vim#L3648). So the the previous tags remain, and 'No tags found.' is not rendered.
It can be confusing when working with a different file, but with wrong tags shown. I have a workaround which defines g:tagbar_type_{a:ftype} with empty ctagsbin here.
What do you think?
This was originally done on purpose so Tagbar wouldn't keep changing when switching between a file you're working on and for example the quickfix list or NerdTree. I can see that it can be a bit confusing though when switching to normal but unsupported files. I'll think about what might be the best solution here.