Simplify the sandbox check, to save on execution time

This commit is contained in:
w0rp 2017-05-25 17:23:16 +01:00
parent 6f76a840f0
commit c31cd12bdd
2 changed files with 8 additions and 4 deletions

View File

@ -80,13 +80,11 @@ endfunction
" See :help sandbox
function! ale#util#InSandbox() abort
try
call setbufvar('%', '', '')
function! s:SandboxCheck() abort
endfunction
catch /^Vim\%((\a\+)\)\=:E48/
" E48 is the sandbox error.
return 1
catch
" If we're not in a sandbox, we'll get another error about an
" invalid buffer variable name.
endtry
return 0

View File

@ -27,12 +27,18 @@ After:
delfunction TestCallback
call ale#linter#Reset()
let g:ale_buffer_info = {}
unlet! b:in_sandbox
Given foobar (Some imaginary filetype):
foo
bar
baz
Execute(ale#util#InSandbox should return 1 when in a sandbox):
sandbox let b:in_sandbox = ale#util#InSandbox()
Assert b:in_sandbox, 'ale#util#InSandbox() returned 0 for a sandbox command'
Execute(ALE shouldn't blow up when run from a sandbox):
AssertEqual 'foobar', &filetype