2017-10-14 18:22:13 -04:00
|
|
|
Before:
|
|
|
|
Save g:ale_echo_cursor
|
|
|
|
Save g:ale_fix_on_save
|
|
|
|
Save g:ale_fixers
|
|
|
|
Save g:ale_lint_on_save
|
2018-07-16 19:18:20 -04:00
|
|
|
Save g:ale_set_highlights
|
|
|
|
Save g:ale_set_lists_synchronously
|
|
|
|
Save g:ale_set_loclist
|
|
|
|
Save g:ale_set_quickfix
|
|
|
|
Save g:ale_set_signs
|
2017-10-14 18:22:13 -04:00
|
|
|
|
|
|
|
let g:ale_run_synchronously = 1
|
2018-07-16 19:18:20 -04:00
|
|
|
let g:ale_set_lists_synchronously = 1
|
|
|
|
" Disable the things we don't need, but leave enabled what we do.
|
|
|
|
let g:ale_echo_cursor = 0
|
|
|
|
let g:ale_set_signs = 0
|
|
|
|
let g:ale_set_quickfix = 0
|
|
|
|
let g:ale_set_loclist = 1
|
|
|
|
let g:ale_set_highlights = 0
|
|
|
|
let g:ale_echo_cursor = 0
|
2017-10-14 18:22:13 -04:00
|
|
|
|
|
|
|
function! TestCallback(buffer, output)
|
|
|
|
return [{'lnum': 1, 'col': 1, 'text': 'xxx'}]
|
|
|
|
endfunction
|
|
|
|
|
2019-02-22 15:48:06 -05:00
|
|
|
function AddLine(buffer, lines) abort
|
2017-10-14 18:22:13 -04:00
|
|
|
return a:lines + ['x']
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
let g:ale_fixers = {
|
|
|
|
\ 'testft': ['AddLine'],
|
|
|
|
\}
|
|
|
|
|
2018-07-16 19:18:20 -04:00
|
|
|
call ale#linter#PreventLoading('testft')
|
2017-10-14 18:22:13 -04:00
|
|
|
call ale#linter#Define('testft', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'callback': 'TestCallback',
|
2017-10-18 18:42:51 -04:00
|
|
|
\ 'executable': has('win32') ? 'cmd' : 'true',
|
2017-10-14 18:22:13 -04:00
|
|
|
\ 'command': 'true',
|
|
|
|
\})
|
|
|
|
|
|
|
|
Given testft (An empty file):
|
|
|
|
|
|
|
|
After:
|
|
|
|
Restore
|
|
|
|
|
|
|
|
unlet! g:ale_run_synchronously
|
|
|
|
unlet! b:ale_quitting
|
|
|
|
delfunction TestCallback
|
|
|
|
delfunction AddLine
|
|
|
|
|
|
|
|
call ale#linter#Reset()
|
|
|
|
call setloclist(0, [])
|
|
|
|
|
|
|
|
Execute(No linting should be done on :wq or :x):
|
|
|
|
let g:ale_lint_on_save = 1
|
|
|
|
let g:ale_fix_on_save = 0
|
|
|
|
|
|
|
|
" First try just the SaveEvent, to be sure that we set errors in the test.
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-14 18:22:13 -04:00
|
|
|
|
2018-07-23 15:41:06 -04:00
|
|
|
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
|
2017-10-14 18:22:13 -04:00
|
|
|
|
|
|
|
" Now try doing it again, but where we run the quit event first.
|
|
|
|
call setloclist(0, [])
|
|
|
|
call ale#events#QuitEvent(bufnr(''))
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-14 18:22:13 -04:00
|
|
|
|
2018-07-23 15:41:06 -04:00
|
|
|
AssertEqual [], ale#test#GetLoclistWithoutModule()
|
2017-10-14 18:22:13 -04:00
|
|
|
|
2017-10-16 19:37:29 -04:00
|
|
|
Execute(No linting should be for :w after :q fails):
|
|
|
|
let g:ale_lint_on_save = 1
|
|
|
|
let g:ale_fix_on_save = 0
|
|
|
|
|
|
|
|
call ale#events#QuitEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-16 19:37:29 -04:00
|
|
|
|
|
|
|
" Simulate 2 seconds passing.
|
|
|
|
let b:ale_quitting -= 1000
|
|
|
|
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-16 19:37:29 -04:00
|
|
|
|
2018-07-23 15:41:06 -04:00
|
|
|
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
|
2017-10-16 19:37:29 -04:00
|
|
|
|
2017-10-14 18:22:13 -04:00
|
|
|
Execute(No linting should be done on :wq or :x after fixing files):
|
|
|
|
let g:ale_lint_on_save = 0
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-14 18:22:13 -04:00
|
|
|
|
2018-07-23 15:41:06 -04:00
|
|
|
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
|
2017-10-14 18:22:13 -04:00
|
|
|
|
|
|
|
" Now try doing it again, but where we run the quit event first.
|
|
|
|
call setloclist(0, [])
|
|
|
|
call ale#events#QuitEvent(bufnr(''))
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-14 18:22:13 -04:00
|
|
|
|
2018-07-23 15:41:06 -04:00
|
|
|
AssertEqual [], ale#test#GetLoclistWithoutModule()
|
2017-10-16 19:37:29 -04:00
|
|
|
|
|
|
|
Execute(Linting should be done after :q fails and fixing files):
|
|
|
|
let g:ale_lint_on_save = 0
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
|
|
|
|
call ale#events#QuitEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-16 19:37:29 -04:00
|
|
|
|
|
|
|
" Simulate 2 seconds passing.
|
|
|
|
let b:ale_quitting -= 1000
|
|
|
|
|
|
|
|
call ale#events#SaveEvent(bufnr(''))
|
2019-02-06 17:00:11 -05:00
|
|
|
call ale#test#FlushJobs()
|
2017-10-16 19:37:29 -04:00
|
|
|
|
2018-07-23 15:41:06 -04:00
|
|
|
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
|