Skip to content
This repository
Browse code

Tolerate corrupt tags files and ctags output (issue #13)

  • Loading branch information...
commit b5e0b6b98282629db3ad11357efbbd98b0e62210 1 parent d727ac0
Peter Odding authored
16  autoload/xolox/easytags.vim
@@ -389,23 +389,33 @@ function! xolox#easytags#read_tagsfile(tagsfile) " {{{2
389 389
   " otherwise Vim might complain with "E432: Tags file not sorted".
390 390
   let headers = []
391 391
   let entries = []
  392
+  let num_invalid = 0
392 393
   for line in readfile(a:tagsfile)
393 394
     if line =~# '^!_TAG_'
394 395
       call add(headers, line)
395 396
     else
396  
-      call add(entries, xolox#easytags#parse_entry(line))
  397
+      let entry = xolox#easytags#parse_entry(line)
  398
+      if !empty(entry)
  399
+        call add(entries, entry)
  400
+      else
  401
+        let num_invalid += 1
  402
+      endif
397 403
     endif
398 404
   endfor
  405
+  if num_invalid > 0
  406
+    call xolox#misc#msg#warn("easytags.vim %s: Ignored %i invalid line(s) in %s!", g:easytags_version, num_invalid, a:tagsfile)
  407
+  endif
399 408
   return [headers, entries]
400 409
 endfunction
401 410
 
402 411
 function! xolox#easytags#parse_entry(line) " {{{2
403  
-  return matchlist(a:line, '^\([^\t]\+\)\t\([^\t]\+\)\t\(.\+\)$')[1:3]
  412
+  let fields = split(a:line, '\t')
  413
+  return len(fields) >= 3 ? fields : []
404 414
 endfunction
405 415
 
406 416
 function! xolox#easytags#parse_entries(lines) " {{{2
407 417
   call map(a:lines, 'xolox#easytags#parse_entry(v:val)')
408  
-  return a:lines
  418
+  return filter(a:lines, '!empty(v:val)')
409 419
 endfunction
410 420
 
411 421
 function! xolox#easytags#write_tagsfile(tagsfile, headers, entries) " {{{2
2  plugin/easytags.vim
@@ -12,7 +12,7 @@ if &cp || exists('g:loaded_easytags')
12 12
   finish
13 13
 endif
14 14
 
15  
-let g:easytags_version = '2.4.4'
  15
+let g:easytags_version = '2.4.5'
16 16
 
17 17
 " Configuration defaults and initialization. {{{1
18 18
 

0 notes on commit b5e0b6b

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