Skip to content
This repository
Browse code

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).
  • Loading branch information...
commit 9762c28efd5e7ecffc35650dd6147149f2f573a7 1 parent 0da0b0d
Peter Odding authored November 26, 2011

Showing 1 changed file with 20 additions and 5 deletions. Show diff stats Hide diff stats

  1. 25  autoload/xolox/easytags.vim
25  autoload/xolox/easytags.vim
... ...
@@ -1,9 +1,9 @@
1 1
 " Vim script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: November 21, 2011
  3
+" Last Change: November 26, 2011
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 
6  
-let g:xolox#easytags#version = '2.7.3'
  6
+let g:xolox#easytags#version = '2.7.4'
7 7
 
8 8
 " Public interface through (automatic) commands. {{{1
9 9
 
@@ -372,9 +372,17 @@ endfunction
372 372
 
373 373
 function! s:save_by_filetype(filter_tags, headers, entries, context)
374 374
   let filetypes = {}
  375
+  let num_invalid = 0
375 376
   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
378 386
       let vim_ft = xolox#easytags#to_vim_ft(ctags_ft)
379 387
       if !has_key(filetypes, vim_ft)
380 388
         let filetypes[vim_ft] = []
@@ -382,10 +390,17 @@ function! s:save_by_filetype(filter_tags, headers, entries, context)
382 390
       call add(filetypes[vim_ft], entry)
383 391
     endif
384 392
   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
385 396
   let directory = xolox#misc#path#absolute(g:easytags_by_filetype)
386 397
   for vim_ft in keys(filetypes)
387 398
     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
389 404
       call xolox#easytags#write_tagsfile(tagsfile, a:headers, filetypes[vim_ft])
390 405
     else
391 406
       call s:filter_merge_tags(a:filter_tags, tagsfile, filetypes[vim_ft], a:context)

0 notes on commit 9762c28

Please sign in to comment.
Something went wrong with that request. Please try again.