diff options
-rw-r--r-- | autoload/ale/engine.vim | 6 | ||||
-rw-r--r-- | doc/ale.txt | 13 | ||||
-rw-r--r-- | test/test_alelint_autocmd.vader | 21 |
3 files changed, 38 insertions, 2 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 9ef3ba39..6ccc3a34 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -321,6 +321,12 @@ function! ale#engine#SetResults(buffer, loclist) abort " Reset the save event marker, used for opening windows, etc. call setbufvar(a:buffer, 'ale_save_event_fired', 0) + " Set a marker showing how many times a buffer has been checked. + call setbufvar( + \ a:buffer, + \ 'ale_linted', + \ getbufvar(a:buffer, 'ale_linted', 0) + 1 + \) " Automatically remove all managed temporary files and directories " now that all jobs have completed. diff --git a/doc/ale.txt b/doc/ale.txt index adcdccdf..95c3c0e1 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2280,6 +2280,19 @@ ale#statusline#Count(buffer) *ale#statusline#Count()* `total` -> The total number of problems. +b:ale_linted *b:ale_linted* + + `b:ale_linted` is set to the number of times a buffer has been checked by + ALE after all linters for one lint cycle have finished checking a buffer. + This variable may not be defined until ALE first checks a buffer, so it + should be accessed with |get()| or |getbufvar()|. For example: > + + " Print a message indicating how many times ALE has checked this buffer. + echo 'ALE has checked this buffer ' . get(b:, 'ale_linted') . ' time(s).' + " Print 'checked' using getbufvar() if a buffer has been checked. + echo getbufvar(bufnr(''), 'ale_linted', 0) > 0 ? 'checked' : 'not checked' +< + ALELintPre *ALELintPre-autocmd* ALELintPost *ALELintPost-autocmd* diff --git a/test/test_alelint_autocmd.vader b/test/test_alelint_autocmd.vader index b19e6b4e..d51694ff 100644 --- a/test/test_alelint_autocmd.vader +++ b/test/test_alelint_autocmd.vader @@ -3,12 +3,18 @@ Before: let g:post_success = 0 let g:ale_run_synchronously = 1 + unlet! b:ale_linted + After: let g:ale_run_synchronously = 0 let g:ale_buffer_info = {} - augroup! VaderTest -Execute (Run a lint cycle, and check that a variable is set in the autocmd): + try + augroup! VaderTest + catch + endtry + +Execute(Run a lint cycle, and check that a variable is set in the autocmd): augroup VaderTest autocmd! autocmd User ALELintPre let g:pre_success = 1 @@ -19,3 +25,14 @@ Execute (Run a lint cycle, and check that a variable is set in the autocmd): AssertEqual g:pre_success, 1 AssertEqual g:post_success, 1 + +Execute(b:ale_linted should be increased after each lint cycle): + AssertEqual get(b:, 'ale_linted'), 0 + + call ale#Lint() + + AssertEqual get(b:, 'ale_linted'), 1 + + call ale#Lint() + + AssertEqual get(b:, 'ale_linted'), 2 |