From 3c37ddcc140ed4f5aa1b85f0dc476b410d1bacb3 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Thu, 19 Sep 2013 12:36:41 +1200 Subject: [PATCH] Handle invalid ctags line numbers, closes #119 --- autoload/tagbar.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index bd00d87..7b4d786 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -2189,6 +2189,10 @@ function! s:ParseTagline(part1, part2, typeinfo, fileinfo) abort if has_key(taginfo.fields, 'lineno') let taginfo.fields.line = str2nr(taginfo.fields.lineno) endif + " Do some sanity checking in case ctags reports invalid line numbers + if taginfo.fields.line < 0 + let taginfo.fields.line = 0 + endif " Make some information easier accessible if has_key(a:typeinfo, 'scope2kind') @@ -2871,6 +2875,13 @@ function! s:HighlightTag(openfolds, ...) abort " instead in that case let tagline = tag.getClosedParentTline() + " Parent tag line number is invalid, better don't do anything + if tagline == 0 + call s:winexec(prevwinnr . 'wincmd w') + redraw + return + endif + " Go to the line containing the tag execute tagline