diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index ff03ed2..234d0dc 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -1731,7 +1731,7 @@ function! s:ParseTagline(part1, part2, typeinfo, fileinfo) let dollar = '' endif let pattern = strpart(pattern, start, end - start) - let taginfo.pattern = '\V\^' . pattern . dollar + let taginfo.pattern = '\V\^\C' . pattern . dollar let prototype = substitute(pattern, '^[[:space:]]\+', '', '') let prototype = substitute(prototype, '[[:space:]]\+$', '', '') let taginfo.prototype = prototype @@ -2362,6 +2362,23 @@ function! s:JumpToTag(stay_in_tagbar) " with the same name are defined in different scopes (e.g. classes) execute taginfo.fields.line + " If the file has been changed but not saved, the tag may not be on the + " saved line anymore, so search for it in the vicinity of the saved line + if match(getline('.'), taginfo.pattern) == -1 + let interval = 1 + let forward = 1 + while search(taginfo.pattern, 'W' . forward ? '' : 'b') == 0 + if !forward + if interval > line('$') + break + else + let interval = interval * 2 + endif + endif + let forward = !forward + endwhile + endif + " Center the tag in the window normal! z.