From e5408f740f9b5f95d7385fb49ca5bbd825aae89d Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Mon, 4 Nov 2013 22:51:38 +1300 Subject: [PATCH] Don't process quickfix-loaded files, closes #176 Certain quickfix-commands like vimgrep have to load all searched files into Vim and will execute the BufReadPost autocmd for all of them. Since Tagbar doesn't need to generate tags for those files pause processing while the command is running. There doesn't seem to be a better way to find out whether vimgrep is running than to set a temporary variable with the QuickFixCmdPre/Post autocmds, see also https://groups.google.com/forum/#!topic/vim_use/sUj5MFGmwD8 --- autoload/tagbar.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index f8afe5d..ec9ec6c 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -976,6 +976,9 @@ function! s:CreateAutocommands() abort autocmd BufDelete,BufUnload,BufWipeout * call \ s:known_files.rm(fnamemodify(expand(''), ':p')) + autocmd QuickFixCmdPre * let s:tagbar_qf_active = 1 + autocmd QuickFixCmdPost * unlet s:tagbar_qf_active + autocmd VimEnter * call s:CorrectFocusOnStartup() augroup END @@ -3185,6 +3188,12 @@ endfunction function! s:AutoUpdate(fname, force) abort call s:LogDebugMessage('AutoUpdate called [' . a:fname . ']') + " This file is being loaded due to a quickfix command like vimgrep, so + " don't process it + if exists('s:tagbar_qf_active') + return + endif + " Get the filetype of the file we're about to process let bufnr = bufnr(a:fname) let ftype = getbufvar(bufnr, '&filetype')