Skip to content

Commit 9762c28

Browse files
committed
Bug fix for file type specific tags file support
While adding some debugging statements to analyze a probably unrelated issue I found a serious bug in the support for file type specific tags files :-(. This commit fixes the bug and adds more debugging output (which would have made me aware of this problem much sooner).
1 parent 0da0b0d commit 9762c28

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

autoload/xolox/easytags.vim

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: November 21, 2011
3+
" Last Change: November 26, 2011
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let g:xolox#easytags#version = '2.7.3'
6+
let g:xolox#easytags#version = '2.7.4'
77

88
" Public interface through (automatic) commands. {{{1
99

@@ -372,20 +372,35 @@ endfunction
372372

373373
function! s:save_by_filetype(filter_tags, headers, entries, context)
374374
let filetypes = {}
375+
let num_invalid = 0
375376
for entry in a:entries
376-
let ctags_ft = matchstr(entry[2], '\tlanguage:\zs\S\+')
377-
if !empty(ctags_ft)
377+
let ctags_ft = matchstr(entry[4], '^language:\zs\S\+$')
378+
if empty(ctags_ft)
379+
" TODO This triggers on entries where the pattern contains tabs. The interesting thing is that Vim reads these entries fine... Fix it in xolox#easytags#read_tagsfile()?
380+
let num_invalid += 1
381+
if &vbs >= 1
382+
call xolox#misc#msg#debug("easytags.vim %s: Skipping tag without 'language:' field: %s",
383+
\ g:xolox#easytags#version, string(entry))
384+
endif
385+
else
378386
let vim_ft = xolox#easytags#to_vim_ft(ctags_ft)
379387
if !has_key(filetypes, vim_ft)
380388
let filetypes[vim_ft] = []
381389
endif
382390
call add(filetypes[vim_ft], entry)
383391
endif
384392
endfor
393+
if num_invalid > 0
394+
call xolox#misc#msg#warn("easytags.vim %s: Skipped %i lines without 'language:' tag!", g:xolox#easytags#version, num_invalid)
395+
endif
385396
let directory = xolox#misc#path#absolute(g:easytags_by_filetype)
386397
for vim_ft in keys(filetypes)
387398
let tagsfile = xolox#misc#path#merge(directory, vim_ft)
388-
if !filereadable(tagsfile)
399+
let existing = filereadable(tagsfile)
400+
call xolox#misc#msg#debug("easytags.vim %s: Writing %s tags to %s tags file %s.",
401+
\ g:xolox#easytags#version, len(filetypes[vim_ft]),
402+
\ existing ? "existing" : "new", tagsfile)
403+
if !existing
389404
call xolox#easytags#write_tagsfile(tagsfile, a:headers, filetypes[vim_ft])
390405
else
391406
call s:filter_merge_tags(a:filter_tags, tagsfile, filetypes[vim_ft], a:context)

0 commit comments

Comments
 (0)