Add an option for completely disabling command history, and add documentation

This commit is contained in:
w0rp 2017-02-16 21:33:44 +00:00
parent 3a2286a1b8
commit ca17b5aebd
4 changed files with 45 additions and 1 deletions

View File

@ -458,7 +458,11 @@ function! s:RunJob(options) abort
\}
endif
if g:ale_history_enabled
call ale#history#Add(l:buffer, l:status, l:job_id, l:command)
else
let g:ale_buffer_info[l:buffer].history = []
endif
endfunction
" Determine which commands to run for a link in a command chain, or

View File

@ -186,6 +186,19 @@ g:ale_enabled *g:ale_enabled*
the |ALEToggle| command, which changes this option.
g:ale_history_enabled *g:ale_history_enabled*
Type: |Number|
Default: `1`
When set to `1`, ALE will remember the last few commands which were run
for every buffer which is open. This information can be viewed with the
|ALEInfo| command. The size of the buffer can be controlled with the
|g:ale_max_buffer_history_size| option.
This option can be disabled if storing a command history is not desired.
g:ale_keep_list_window_open *g:ale_keep_list_window_open*
Type: |Number|
@ -311,6 +324,19 @@ g:ale_linters *g:ale_linters*
let g:ale_linters = {'c': 'all'}
<
g:ale_max_buffer_history_size *g:ale_max_buffer_history_size*
Type: |Number|
Default: `20`
This setting controls the maximum number of commands which will be stored in
the command history used for |ALEInfo|. Command history will be rotated in
a FIFO manner. If set to a number <= 0, then the history will be
continuously set to an empty |List|.
History can be disabled completely with |g:ale_history_enabled|.
g:ale_open_list *g:ale_open_list*
Type: |Number|

View File

@ -134,6 +134,9 @@ let g:ale_warn_about_trailing_whitespace =
" A flag for controlling the maximum size of the command history to store.
let g:ale_max_buffer_history_size = get(g:, 'ale_max_buffer_history_size', 20)
" A flag for enabling or disabling the command history.
let g:ale_history_enabled = get(g:, 'ale_history_enabled', 1)
function! s:ALEInitAuGroups() abort
augroup ALERunOnTextChangedGroup
autocmd!

View File

@ -16,6 +16,7 @@ Before:
\})
After:
let g:ale_history_enabled = 1
unlet g:history
let g:ale_buffer_info = {}
let g:ale_max_buffer_history_size = 20
@ -40,6 +41,16 @@ Execute(History should be set when commands are run):
" The Job ID will change each time, but we can check the type.
AssertEqual type(1), type(g:history[0].job_id)
Execute(History should be not set when disabled):
AssertEqual 'foobar', &filetype
let g:ale_history_enabled = 0
call ale#Lint()
call ale#engine#WaitForJobs(2000)
AssertEqual 0, len(g:ale_buffer_info[bufnr('%')].history)
Execute(History items should be popped after going over the max):
let g:ale_buffer_info[1] = {
\ 'history': map(range(20), '{''status'': ''started'', ''job_id'': v:val, ''command'': ''foobar''}'),