mirror of
https://github.com/gryf/tagbar.git
synced 2026-02-14 12:55:48 +01:00
Added fsize calculation in fileinfo so better tracking can be used to display in tagbar window
This commit is contained in:
@@ -1158,22 +1158,6 @@ function! s:ProcessFile(fname, ftype) abort
|
||||
return
|
||||
endif
|
||||
|
||||
" If the file size limit it set, then check the file size to see if
|
||||
" this file should be ignored or not.
|
||||
if g:tagbar_file_size_limit > 0
|
||||
let fsize = getfsize(expand('%'))
|
||||
if fsize > g:tagbar_file_size_limit && !exists('b:tagbar_force_update')
|
||||
call tagbar#debug#log('[ProcessFile] File size too large (' . fsize .
|
||||
\ ' bytes) - limit set to ' . g:tagbar_file_size_limit)
|
||||
if !exists('b:tagbar_file_exceeds_limit')
|
||||
echom 'File size too large (' . fsize .
|
||||
\ ' bytes) - Not processing file (see help for g:tagbar_file_size_limit).'
|
||||
let b:tagbar_file_exceeds_limit = 1
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
let typeinfo = s:known_types[a:ftype]
|
||||
|
||||
" If the file has only been updated preserve the fold states, otherwise
|
||||
@@ -1197,7 +1181,14 @@ function! s:ProcessFile(fname, ftype) abort
|
||||
|
||||
call tagbar#debug#log('typeinfo for file to process: ' . string(typeinfo))
|
||||
|
||||
if g:tagbar_use_cache
|
||||
if g:tagbar_file_size_limit > 0
|
||||
\ && fileinfo.fsize > g:tagbar_file_size_limit
|
||||
\ && !exists('b:tagbar_force_update')
|
||||
call tagbar#debug#log('File size exceeds defined limit')
|
||||
let fileinfo.fsize_exceeded = 1
|
||||
call s:known_files.put(fileinfo)
|
||||
return
|
||||
elseif g:tagbar_use_cache
|
||||
" Use a temporary files for ctags processing instead of the original one.
|
||||
" This allows using Tagbar for files accessed with netrw, and also doesn't
|
||||
" slow down Tagbar for files that sit on slow network drives.
|
||||
@@ -1216,6 +1207,7 @@ function! s:ProcessFile(fname, ftype) abort
|
||||
return
|
||||
endif
|
||||
let fileinfo.mtime = getftime(tempfile)
|
||||
let fileinfo.fsize_exceeded = 0
|
||||
|
||||
let ctags_output = s:ExecuteCtagsOnFile(tempfile, a:fname, typeinfo)
|
||||
|
||||
@@ -1224,6 +1216,7 @@ function! s:ProcessFile(fname, ftype) abort
|
||||
endif
|
||||
else
|
||||
call tagbar#debug#log('File caching disabled')
|
||||
let fileinfo.fsize_exceeded = 0
|
||||
let ctags_output = s:ExecuteCtagsOnFile(a:fname, a:fname, typeinfo)
|
||||
endif
|
||||
|
||||
@@ -1864,7 +1857,16 @@ function! s:RenderContent(...) abort
|
||||
|
||||
let typeinfo = fileinfo.typeinfo
|
||||
|
||||
if !empty(fileinfo.getTags())
|
||||
if fileinfo.fsize_exceeded == 1
|
||||
if g:tagbar_compact
|
||||
silent 0put ='\" File size [' . fileinfo.fsize . 'B] exceeds limit'
|
||||
else
|
||||
silent put ='\" File size exceeds defined limit'
|
||||
silent put ='\" File Size [' . fileinfo.fsize . ' bytes]'
|
||||
silent put ='\" Limit [' . g:tagbar_file_size_limit . ' bytes]'
|
||||
silent put ='\" Use TagbarForceUpdate override'
|
||||
endif
|
||||
elseif !empty(fileinfo.getTags())
|
||||
" Print tags
|
||||
call s:PrintKinds(typeinfo, fileinfo)
|
||||
else
|
||||
@@ -3594,13 +3596,12 @@ function! tagbar#Update() abort
|
||||
call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0)
|
||||
endfunction
|
||||
|
||||
" tagbar#ForceUpdate() {{{2
|
||||
" 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
|
||||
unlet b:tagbar_file_exceeds_limit
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ function! tagbar#prototypes#fileinfo#new(fname, ftype, typeinfo) abort
|
||||
" File modification time
|
||||
let newobj.mtime = getftime(a:fname)
|
||||
|
||||
" Get file size
|
||||
let newobj.fsize = getfsize(a:fname)
|
||||
|
||||
" The vim file type
|
||||
let newobj.ftype = a:ftype
|
||||
|
||||
@@ -52,6 +55,10 @@ function! tagbar#prototypes#fileinfo#new(fname, ftype, typeinfo) abort
|
||||
let newobj.openKindFold = function(s:add_snr('s:openKindFold'))
|
||||
let newobj.closeKindFold = function(s:add_snr('s:closeKindFold'))
|
||||
|
||||
" This is used during file processing. If the limit is exceeded at that
|
||||
" point, then mark this flag for displaying to the tagbar window
|
||||
let newobj.fsize_exceeded = 0
|
||||
|
||||
return newobj
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user