diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim index 62a4f9b..9111db3 100644 --- a/autoload/ale/fix.vim +++ b/autoload/ale/fix.vim @@ -392,7 +392,13 @@ function! s:GetCallbacks() abort endif endif - call add(l:corrected_list, ale#util#GetFunction(l:Item)) + try + call add(l:corrected_list, ale#util#GetFunction(l:Item)) + catch /E475/ + " Rethrow exceptions for failing to get a function so we can print + " a friendly message about it. + throw 'BADNAME ' . v:exception + endtry endfor return l:corrected_list @@ -427,7 +433,7 @@ function! ale#fix#Fix(...) abort try let l:callback_list = s:GetCallbacks() - catch /E700/ + catch /E700\|BADNAME/ let l:function_name = join(split(split(v:exception, ':')[3])) let l:echo_message = printf( \ 'There is no fixer named `%s`. Check :ALEFixSuggest', diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader index 817c243..5b66c92 100644 --- a/test/fix/test_ale_fix.vader +++ b/test/fix/test_ale_fix.vader @@ -574,6 +574,16 @@ Execute(ALE should print a message telling you something isn't a valid fixer whe AssertEqual 'There is no fixer named `invalidname`. Check :ALEFixSuggest', GetLastMessage() +Execute(ALE should complain about invalid fixers with minuses in the name): + let g:ale_fixers.testft = ['foo-bar'] + ALEFix + + AssertEqual 'There is no fixer named `foo-bar`. Check :ALEFixSuggest', GetLastMessage() + +Execute(ALE should tolerate valid fixers with minuses in the name): + let g:ale_fixers.testft = ['prettier-standard'] + ALEFix + Execute(Test fixing with chained callbacks): let g:ale_fixers.testft = ['FirstChainCallback'] ALEFix