From a0526a6d5a26533132acbca8c581af9affe5d04f Mon Sep 17 00:00:00 2001 From: Flemming Madsen Date: Mon, 21 Oct 2019 15:19:45 +0200 Subject: [PATCH] Fix issue where --regex based file types can output duplicate lines when --sort=no (#471) Fix issue where --regex based filetypes can output duplicate lines when --sort=no Co-authored-by: Flemming Madsen --- autoload/tagbar.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index b38b6d9..0829845 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1025,11 +1025,13 @@ function! s:ProcessFile(fname, ftype) abort " Parse the ctags output lines call tagbar#debug#log('Parsing ctags output') let rawtaglist = split(ctags_output, '\n\+') + let seen = {} for line in rawtaglist - " skip comments - if line =~# '^!_TAG_' + " skip comments and duplicates (can happen when --sort=no) + if line =~# '^!_TAG_' || has_key(seen, line) continue endif + let seen[line] = 1 let parts = split(line, ';"') if len(parts) == 2 " Is a valid tag line @@ -1259,7 +1261,7 @@ function! s:ParseTagline(part1, part2, typeinfo, fileinfo) abort endfunction " s:ProcessTag() {{{2 -function s:ProcessTag(name, filename, pattern, fields, is_split, typeinfo, fileinfo) abort +function! s:ProcessTag(name, filename, pattern, fields, is_split, typeinfo, fileinfo) abort if a:is_split let taginfo = tagbar#prototypes#splittag#new(a:name) else