1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
Before:
Save g:ale_run_synchronously
let b:old_filetype = &filetype
let g:ale_run_synchronously = 1
noautocmd let &filetype = 'foobar'
function! TestCallback(buffer, output)
return [{'text': 'x', 'lnum': 1}]
endfunction
call ale#linter#Define('foobar', {
\ 'name': 'buffer_linter',
\ 'callback': 'TestCallback',
\ 'executable': has('win32') ? 'cmd': 'true',
\ 'command': 'true',
\ 'read_buffer': 0,
\})
call ale#linter#Define('foobar2', {
\ 'name': 'buffer_linter',
\ 'callback': 'TestCallback',
\ 'executable': has('win32') ? 'cmd': 'true',
\ 'command': 'true',
\ 'read_buffer': 0,
\})
After:
Restore
noautocmd let &filetype = b:old_filetype
unlet b:old_filetype
delfunction TestCallback
if has_key(g:ale_buffer_info, bufnr(''))
call remove(g:ale_buffer_info, bufnr(''))
endif
call ale#Queue(0)
Execute(Error should be removed when the filetype changes to something else we cannot check):
call ale#Queue(0)
sleep 1ms
AssertEqual 1, len(getloclist(0))
noautocmd let &filetype = 'foobar2'
call ale#Queue(0)
sleep 1ms
" We should get some items from the second filetype.
AssertEqual 1, len(getloclist(0))
noautocmd let &filetype = 'xxx'
call ale#Queue(0)
sleep 1ms
AssertEqual 0, len(getloclist(0))
|