mirror of https://github.com/dense-analysis/ale
Tell users when a fixer does not exist, and make the no fixers message softer
This commit is contained in:
parent
e4cd371621
commit
d97924b698
|
@ -352,11 +352,21 @@ function! ale#fix#Fix(...) abort
|
||||||
throw "fixing_flag must be either '' or 'save_file'"
|
throw "fixing_flag must be either '' or 'save_file'"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
try
|
||||||
let l:callback_list = s:GetCallbacks()
|
let l:callback_list = s:GetCallbacks()
|
||||||
|
catch /E700/
|
||||||
|
let l:function_name = join(split(split(v:exception, ':')[3]))
|
||||||
|
echom printf(
|
||||||
|
\ 'There is no fixer named `%s`. Check :ALEFixSuggest',
|
||||||
|
\ l:function_name,
|
||||||
|
\)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
endtry
|
||||||
|
|
||||||
if empty(l:callback_list)
|
if empty(l:callback_list)
|
||||||
if l:fixing_flag is# ''
|
if l:fixing_flag is# ''
|
||||||
echoerr 'No fixers have been defined. Try :ALEFixSuggest'
|
echom 'No fixers have been defined. Try :ALEFixSuggest'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -71,6 +71,16 @@ Before:
|
||||||
\})
|
\})
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function GetLastMessage()
|
||||||
|
redir => l:output
|
||||||
|
silent mess
|
||||||
|
redir END
|
||||||
|
|
||||||
|
let l:lines = split(l:output, "\n")
|
||||||
|
|
||||||
|
return empty(l:lines) ? '' : l:lines[-1]
|
||||||
|
endfunction
|
||||||
|
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
unlet! g:ale_run_synchronously
|
unlet! g:ale_run_synchronously
|
||||||
|
@ -88,6 +98,7 @@ After:
|
||||||
delfunction RemoveLastLineOneArg
|
delfunction RemoveLastLineOneArg
|
||||||
delfunction TestCallback
|
delfunction TestCallback
|
||||||
delfunction SetUpLinters
|
delfunction SetUpLinters
|
||||||
|
delfunction GetLastMessage
|
||||||
|
|
||||||
call ale#test#RestoreDirectory()
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
|
@ -104,14 +115,17 @@ After:
|
||||||
|
|
||||||
let g:ale_fix_buffer_data = {}
|
let g:ale_fix_buffer_data = {}
|
||||||
|
|
||||||
|
" Clear the messages between tests.
|
||||||
|
echomsg ''
|
||||||
|
|
||||||
Given testft (A file with three lines):
|
Given testft (A file with three lines):
|
||||||
a
|
a
|
||||||
b
|
b
|
||||||
c
|
c
|
||||||
|
|
||||||
Execute(ALEFix should complain when there are no functions to call):
|
Execute(ALEFix should complain when there are no functions to call):
|
||||||
AssertThrows ALEFix
|
ALEFix
|
||||||
AssertEqual 'Vim(echoerr):No fixers have been defined. Try :ALEFixSuggest', g:vader_exception
|
AssertEqual 'No fixers have been defined. Try :ALEFixSuggest', GetLastMessage()
|
||||||
|
|
||||||
Execute(ALEFix should apply simple functions):
|
Execute(ALEFix should apply simple functions):
|
||||||
let g:ale_fixers.testft = ['AddCarets']
|
let g:ale_fixers.testft = ['AddCarets']
|
||||||
|
@ -450,3 +464,9 @@ Expect(An extra line should be added):
|
||||||
b
|
b
|
||||||
c
|
c
|
||||||
d
|
d
|
||||||
|
|
||||||
|
Execute(ALE should print a message telling you something isn't a valid fixer when you type some nonsense):
|
||||||
|
let g:ale_fixers.testft = ['CatLine', 'invalidname']
|
||||||
|
ALEFix
|
||||||
|
|
||||||
|
AssertEqual 'There is no fixer named `invalidname`. Check :ALEFixSuggest', GetLastMessage()
|
||||||
|
|
Loading…
Reference in New Issue