Break up ShouldDoNothing checks into separate lines, so it's possible to profile them

This commit is contained in:
w0rp 2017-10-14 16:51:12 +01:00
parent 618074a053
commit 5204f2dbc2

View File

@ -41,14 +41,40 @@ endfunction
" A function for checking various conditions whereby ALE just shouldn't
" attempt to do anything, say if particular buffer types are open in Vim.
function! ale#ShouldDoNothing(buffer) abort
" The checks are split into separate if statements to make it possible to
" profile each check individually with Vim's profiling tools.
" Do nothing for blacklisted files
" OR if ALE is running in the sandbox
return index(g:ale_filetype_blacklist, &filetype) >= 0
\ || (exists('*getcmdwintype') && !empty(getcmdwintype()))
\ || ale#util#InSandbox()
\ || !ale#Var(a:buffer, 'enabled')
\ || ale#FileTooLarge()
\ || getbufvar(a:buffer, '&l:statusline') =~# 'CtrlPMode.*funky'
if index(g:ale_filetype_blacklist, &filetype) >= 0
return 1
endif
" Do nothing if running from command mode
if exists('*getcmdwintype') && !empty(getcmdwintype())
return 1
endif
" Do nothing if running in the sandbox
if ale#util#InSandbox()
return 1
endif
" Do nothing if ALE is disabled.
if !ale#Var(a:buffer, 'enabled')
return 1
endif
" Do nothing if the file is too large.
if ale#FileTooLarge()
return 1
endif
" Do nothing from CtrlP buffers with CtrlP-funky.
if getbufvar(a:buffer, '&l:statusline') =~# 'CtrlPMode.*funky'
return 1
endif
return 0
endfunction
" (delay, [linting_flag, buffer_number])