From 014d27c882b10c6c6ba1b32ec0ad1ce993b108eb Mon Sep 17 00:00:00 2001 From: w0rp Date: Fri, 1 Jun 2018 21:03:22 +0100 Subject: [PATCH] #1621 - Tolerate SetOptions calls when ALE is loaded in a weird way --- autoload/ale/pattern_options.vim | 3 ++- test/test_pattern_options.vader | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/autoload/ale/pattern_options.vim b/autoload/ale/pattern_options.vim index c445a9ed..d1f91785 100644 --- a/autoload/ale/pattern_options.vim +++ b/autoload/ale/pattern_options.vim @@ -23,7 +23,8 @@ function! s:CmpPatterns(left_item, right_item) abort endfunction function! ale#pattern_options#SetOptions(buffer) abort - if !g:ale_pattern_options_enabled || empty(g:ale_pattern_options) + if !get(g:, 'ale_pattern_options_enabled', 0) + \|| empty(get(g:, 'ale_pattern_options', 0)) return endif diff --git a/test/test_pattern_options.vader b/test/test_pattern_options.vader index 0e26eaaa..f439afbd 100644 --- a/test/test_pattern_options.vader +++ b/test/test_pattern_options.vader @@ -90,3 +90,14 @@ Execute(Patterns should be applied after the Dictionary changes): call ale#pattern_options#SetOptions(bufnr('')) AssertEqual 666, b:some_option + +Execute(SetOptions should tolerate settings being unset): + " This might happen if ALE is loaded in a weird way, so tolerate it. + unlet! g:ale_pattern_options + unlet! g:ale_pattern_options_enabled + + call ale#pattern_options#SetOptions(bufnr('')) + + let g:ale_pattern_options_enabled = 1 + + call ale#pattern_options#SetOptions(bufnr(''))