From c31cd12bdd941e9a326d89b21d187224c661c485 Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 25 May 2017 17:23:16 +0100 Subject: [PATCH] Simplify the sandbox check, to save on execution time --- autoload/ale/util.vim | 6 ++---- test/test_sandbox_execution.vader | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim index b796d63..03abacb 100644 --- a/autoload/ale/util.vim +++ b/autoload/ale/util.vim @@ -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 diff --git a/test/test_sandbox_execution.vader b/test/test_sandbox_execution.vader index a4cd84d..dc0cb01 100644 --- a/test/test_sandbox_execution.vader +++ b/test/test_sandbox_execution.vader @@ -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