From b1c6cbc2d8d3ce7999645653987de05112b8e71d Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Thu, 15 Jun 2017 17:27:30 +1200 Subject: [PATCH] Short-circuit parent searches if tag doesn't have line number --- autoload/tagbar.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index fde6f37..cd65fd0 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -2672,6 +2672,14 @@ function! s:add_tag_recursive(parent, taginfo, pathlist) abort " Start at line 0 so that pseudotags get included let minline = 0 for candidate in parents + " If the line number of the current tag is 0 then we have no way + " of determining the best candidate by comparing line numbers. + " Just use the first one we have. + if a:taginfo.fields.line == 0 + let parent = candidate + break + endif + if candidate.fields.line <= a:taginfo.fields.line && \ candidate.fields.line >= minline let parent = candidate