summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fix.vim13
-rw-r--r--test/test_history_saving.vader25
2 files changed, 37 insertions, 1 deletions
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim
index 80f46c27..e1210f17 100644
--- a/autoload/ale/fix.vim
+++ b/autoload/ale/fix.vim
@@ -96,6 +96,11 @@ function! s:HandleExit(job_id, exit_code) abort
endif
let l:job_info = remove(s:job_info_map, a:job_id)
+ let l:buffer = l:job_info.buffer
+
+ if g:ale_history_enabled
+ call ale#history#SetExitCode(l:buffer, a:job_id, a:exit_code)
+ endif
if has_key(l:job_info, 'file_to_read')
let l:job_info.output = readfile(l:job_info.file_to_read)
@@ -108,7 +113,7 @@ function! s:HandleExit(job_id, exit_code) abort
\ : l:job_info.input
call s:RunFixer({
- \ 'buffer': l:job_info.buffer,
+ \ 'buffer': l:buffer,
\ 'input': l:input,
\ 'callback_list': l:job_info.callback_list,
\ 'callback_index': l:job_info.callback_index + 1,
@@ -209,6 +214,12 @@ function! s:RunJob(options) abort
let l:job_id = ale#job#Start(l:command, l:job_options)
endif
+ let l:status = l:job_id ? 'started' : 'failed'
+
+ if g:ale_history_enabled
+ call ale#history#Add(l:buffer, l:status, l:job_id, l:command)
+ endif
+
if l:job_id == 0
return 0
endif
diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader
index 3b8fb2aa..3ccc1691 100644
--- a/test/test_history_saving.vader
+++ b/test/test_history_saving.vader
@@ -1,7 +1,10 @@
Before:
Save g:ale_max_buffer_history_size
Save g:ale_history_log_output
+ Save g:ale_run_synchronously
+ unlet! b:ale_fixers
+ unlet! b:ale_enabled
unlet! b:ale_history
" Temporarily set the shell to /bin/sh, if it isn't already set that way.
@@ -13,6 +16,10 @@ Before:
let g:ale_max_buffer_history_size = 20
let g:ale_history_log_output = 0
+ function! TestFixer(buffer)
+ return {'command': 'echo foo'}
+ endfunction
+
function! CollectResults(buffer, output)
return []
endfunction
@@ -28,6 +35,8 @@ Before:
After:
Restore
+ unlet! b:ale_fixers
+ unlet! b:ale_enabled
" Clear the history we changed.
unlet! b:ale_history
@@ -40,6 +49,7 @@ After:
let g:ale_buffer_info = {}
let g:ale_max_buffer_history_size = 20
call ale#linter#Reset()
+ delfunction TestFixer
delfunction CollectResults
Given foobar (Some imaginary filetype):
@@ -108,3 +118,18 @@ Execute(Nothing should be added to history if the size is too low):
call ale#history#Add(1, 'started', 347, 'last command')
AssertEqual [], ale#history#Get(bufnr(''))
+
+Given foobar(Some file with an imaginary filetype):
+ a
+ b
+ c
+
+Execute(The history should be updated when fixers are run):
+ let b:ale_fixers = {'foobar': ['TestFixer']}
+ let b:ale_enabled = 0
+ let g:ale_run_synchronously = 1
+
+ ALEFix
+
+ AssertEqual ['finished'], map(copy(b:ale_history), 'v:val.status')
+ AssertEqual '/bin/sh -c echo foo ', split(join(b:ale_history[0].command), '<')[0]