aboutsummaryrefslogtreecommitdiffstats
path: root/autoload
diff options
context:
space:
mode:
authorPeter Odding <peter@peterodding.com>2011-06-24 03:00:23 +0200
committerPeter Odding <peter@peterodding.com>2011-06-24 03:00:23 +0200
commitb5e0b6b98282629db3ad11357efbbd98b0e62210 (patch)
treebeae15f5dee1980122bdf5e87d19a8fdfbbf72ea /autoload
parentd727ac0cb7b03747d0688d939210af07da4cad60 (diff)
downloadvim-easytags-b5e0b6b98282629db3ad11357efbbd98b0e62210.tar.gz
Tolerate corrupt tags files and ctags output (issue #13)
Diffstat (limited to 'autoload')
-rw-r--r--autoload/xolox/easytags.vim16
1 files changed, 13 insertions, 3 deletions
diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim
index 6a1de96..bbea4dc 100644
--- a/autoload/xolox/easytags.vim
+++ b/autoload/xolox/easytags.vim
@@ -389,23 +389,33 @@ function! xolox#easytags#read_tagsfile(tagsfile) " {{{2
" otherwise Vim might complain with "E432: Tags file not sorted".
let headers = []
let entries = []
+ let num_invalid = 0
for line in readfile(a:tagsfile)
if line =~# '^!_TAG_'
call add(headers, line)
else
- call add(entries, xolox#easytags#parse_entry(line))
+ let entry = xolox#easytags#parse_entry(line)
+ if !empty(entry)
+ call add(entries, entry)
+ else
+ let num_invalid += 1
+ endif
endif
endfor
+ if num_invalid > 0
+ call xolox#misc#msg#warn("easytags.vim %s: Ignored %i invalid line(s) in %s!", g:easytags_version, num_invalid, a:tagsfile)
+ endif
return [headers, entries]
endfunction
function! xolox#easytags#parse_entry(line) " {{{2
- return matchlist(a:line, '^\([^\t]\+\)\t\([^\t]\+\)\t\(.\+\)$')[1:3]
+ let fields = split(a:line, '\t')
+ return len(fields) >= 3 ? fields : []
endfunction
function! xolox#easytags#parse_entries(lines) " {{{2
call map(a:lines, 'xolox#easytags#parse_entry(v:val)')
- return a:lines
+ return filter(a:lines, '!empty(v:val)')
endfunction
function! xolox#easytags#write_tagsfile(tagsfile, headers, entries) " {{{2