diff options
author | w0rp <devw0rp@gmail.com> | 2017-02-16 21:18:03 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-02-16 21:18:03 +0000 |
commit | 3a2286a1b8d8b2004b0a10656192b6823a89f690 (patch) | |
tree | c7faadd3487262595b393645ef518dab0f00b82b /autoload | |
parent | 434ff01f59835c06a799585a4dbbbb3711d95b64 (diff) | |
download | ale-3a2286a1b8d8b2004b0a10656192b6823a89f690.zip |
Refactor history management functions into their own file
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/engine.vim | 28 | ||||
-rw-r--r-- | autoload/ale/history.vim | 26 |
2 files changed, 28 insertions, 26 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index b54ad6ee..ae31c8c8 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -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 diff --git a/autoload/ale/history.vim b/autoload/ale/history.vim new file mode 100644 index 00000000..6524b916 --- /dev/null +++ b/autoload/ale/history.vim @@ -0,0 +1,26 @@ +" Author: w0rp <devw0rp@gmail.com> +" Description: Tools for managing command history +" +function! ale#history#Add(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 |