summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-07 19:47:20 +0000
committerw0rp <devw0rp@gmail.com>2017-11-07 19:47:20 +0000
commitd97924b6986216aea3eae68a3fdc27b9bde341bb (patch)
treeb3bd4ab24e645bb9fb265a1a1f82d2348998669d
parente4cd371621ff2617e42ff5178b4690ebc00f67a4 (diff)
downloadale-d97924b6986216aea3eae68a3fdc27b9bde341bb.zip
Tell users when a fixer does not exist, and make the no fixers message softer
-rw-r--r--autoload/ale/fix.vim14
-rw-r--r--test/test_ale_fix.vader24
2 files changed, 34 insertions, 4 deletions
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index a9bb7d48..677fb3da 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -352,11 +352,21 @@ function! ale#fix#Fix(...) abort
throw "fixing_flag must be either '' or 'save_file'"
endif
- let l:callback_list = s:GetCallbacks()
+ try
+ 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 l:fixing_flag is# ''
- echoerr 'No fixers have been defined. Try :ALEFixSuggest'
+ echom 'No fixers have been defined. Try :ALEFixSuggest'
endif
return 0
diff --git a/test/test_ale_fix.vader b/test/test_ale_fix.vader
index fac9a25b..fbf4755a 100644
--- a/test/test_ale_fix.vader
+++ b/test/test_ale_fix.vader
@@ -71,6 +71,16 @@ Before:
\})
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:
Restore
unlet! g:ale_run_synchronously
@@ -88,6 +98,7 @@ After:
delfunction RemoveLastLineOneArg
delfunction TestCallback
delfunction SetUpLinters
+ delfunction GetLastMessage
call ale#test#RestoreDirectory()
@@ -104,14 +115,17 @@ After:
let g:ale_fix_buffer_data = {}
+ " Clear the messages between tests.
+ echomsg ''
+
Given testft (A file with three lines):
a
b
c
Execute(ALEFix should complain when there are no functions to call):
- AssertThrows ALEFix
- AssertEqual 'Vim(echoerr):No fixers have been defined. Try :ALEFixSuggest', g:vader_exception
+ ALEFix
+ AssertEqual 'No fixers have been defined. Try :ALEFixSuggest', GetLastMessage()
Execute(ALEFix should apply simple functions):
let g:ale_fixers.testft = ['AddCarets']
@@ -450,3 +464,9 @@ Expect(An extra line should be added):
b
c
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()