Closed ericsunplus closed 4 years ago
Off the top of my head I don't know how to do this, although I'm sure there is a way. I've wanted myself to avoid generated tags on super large files (which are often generated anyway). We should figure out how to do this cleanly and document it.
Something like this could be added to the ProcessFile() routine.
function! s:ProcessFile(fname, ftype) abort
let linecount = line('$')
if linecount > g:tagbar_file_size_limit && !exists('b:tagbar_force_update')
echo 'File too large (' . linecount . ' lines). not processing file'
return
endif
...
endfunction
" tagbar#ForceUpdate() {{{2
function! tagbar#ForceUpdate() abort
if !exists('b:tagbar_force_update')
let b:tagbar_force_update = 1
call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 1)
unlet b:tagbar_force_update
endif
endfunction
This along with a global g:tagbar_file_size_limit
could be used to simply not update the file, and then you could call tagbar#ForceUpdate()
to manually update that specific file.
Note: Haven't actually coded this up... just thinking outloud
@raven42 , thank you, the patch works fine, the only exception is the File too large (' . linecount . ' lines). not processing file
repeat 3 times for a single file
I've pushed an initial go for this. It seems to be stable enough, but I'd like to add an option to display in the tagbar window that the file was ignored or not processed. I'm not sure how best to do that though.
I agree displaying something as an indication of why a file was not processed is probably a really good idea. No I don't have any great ideas how to do this. Probably just stuffing an explanation into the Tagbar buffer will do the trick.
Hi there,
I am using tagbar for a long time and enjoy its' feature. However, recently I am profiling a problem that my vim runs very slow when loading a large header file, it turns out the root cause is tagbar makes a lot of iteration for this header file and spend quite a long time. The following is from my profiling result
As can be seen,
131_ProcessFile
takes approx. 80s because of the iterations inside.So is there a way to disable tagbar for very large file (for example lines >= 10000)?