From 44ce05fb5dc6fb67531dc57ffbb6e3799ed8c0ab Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sat, 23 Jun 2012 01:30:45 +1200 Subject: [PATCH] Fix highlighting tags in closed folds If a tag was in a closed fold that was itself in a closed fold, and those folds existed since the initial display (for example by using the g:tagbar_foldlevel option), then intermediate tags could have invalid tline values which resulted in the search pattern failing. --- autoload/tagbar.vim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 8e0d3bb..a205910 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1191,17 +1191,22 @@ endfunction " s:BaseTag.getClosedParentTline() {{{3 function! s:BaseTag.getClosedParentTline() dict - let tagline = self.tline + let tagline = self.tline let fileinfo = self.fileinfo - let parent = self.parent - while !empty(parent) + " Find the first closed parent, starting from the top of the hierarchy. + let parents = [] + let curparent = self.parent + while !empty(curparent) + call add(parents, curparent) + let curparent = curparent.parent + endwhile + for parent in reverse(parents) if parent.isFolded() let tagline = parent.tline break endif - let parent = parent.parent - endwhile + endfor return tagline endfunction