From 2955f71856536d503c79c15daab3de890a6d83e9 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sun, 25 Sep 2016 00:24:04 +1200 Subject: [PATCH] Try to jump to the right tag column, closes #326 --- autoload/tagbar.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 52a87ff..5b9d10b 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1261,7 +1261,7 @@ function! s:BaseTag._init(name) abort dict let self.name = a:name let self.fields = {} let self.fields.line = 0 - let self.fields.column = 1 + let self.fields.column = 0 let self.prototype = '' let self.path = '' let self.fullpath = a:name @@ -3098,9 +3098,15 @@ function! s:JumpToTag(stay_in_tagbar) abort let taginfo.fileinfo.fline[curline] = taginfo endif - " Center the tag in the window and jump to the correct column if available + " Center the tag in the window and jump to the correct column if + " available, otherwise try to find it in the line normal! z. - call cursor(taginfo.fields.line, taginfo.fields.column) + if taginfo.fields.column > 0 + call cursor(taginfo.fields.line, taginfo.fields.column) + else + call cursor(taginfo.fields.line, 1) + call search(taginfo.name, 'c', line('.')) + endif normal! zv