Refactor history management functions into their own file

This commit is contained in:
w0rp
2017-02-16 21:18:03 +00:00
parent 434ff01f59
commit 3a2286a1b8
4 changed files with 39 additions and 37 deletions

View File

@@ -9,30 +9,6 @@
" output: The array of lines for the output of the job.
let s:job_info_map = {}
function! ale#engine#AddToHistory(buffer, status, job_id, command) abort
if g:ale_max_buffer_history_size <= 0
" Don't save anything if the history isn't a positive number.
let g:ale_buffer_info[a:buffer].history = []
return
endif
let l:history = g:ale_buffer_info[a:buffer].history
" Remove the first item if we hit the max history size.
if len(l:history) >= g:ale_max_buffer_history_size
let l:history = l:history[1:]
endif
call add(l:history, {
\ 'status': a:status,
\ 'job_id': a:job_id,
\ 'command': a:command,
\})
let g:ale_buffer_info[a:buffer].history = l:history
endfunction
function! s:GetJobID(job) abort
if has('nvim')
"In NeoVim, job values are just IDs.
@@ -471,7 +447,7 @@ function! s:RunJob(options) abort
" Add the job to the list of jobs, so we can track them.
call add(g:ale_buffer_info[l:buffer].job_list, l:job)
let l:status = 'ran'
let l:status = 'started'
let l:job_id = s:GetJobID(l:job)
" Store the ID for the job in the map to read back again.
let s:job_info_map[l:job_id] = {
@@ -482,7 +458,7 @@ function! s:RunJob(options) abort
\}
endif
call ale#engine#AddToHistory(l:buffer, l:status, l:job_id, l:command)
call ale#history#Add(l:buffer, l:status, l:job_id, l:command)
endfunction
" Determine which commands to run for a link in a command chain, or