mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Update Ale.
This commit is contained in:
@ -0,0 +1,76 @@
|
||||
Given foobar (Some imaginary filetype):
|
||||
var y = 3+3;
|
||||
var y = 3
|
||||
|
||||
Before:
|
||||
Save g:ale_buffer_info
|
||||
Save g:ale_echo_cursor
|
||||
Save g:ale_run_synchronously
|
||||
Save g:ale_set_highlights
|
||||
Save g:ale_set_loclist
|
||||
Save g:ale_set_quickfix
|
||||
Save g:ale_set_signs
|
||||
Save g:ale_command_wrapper
|
||||
|
||||
let g:ale_command_wrapper = ''
|
||||
let g:ale_buffer_info = {}
|
||||
let g:ale_run_synchronously = 1
|
||||
unlet! g:ale_run_synchronously_callbacks
|
||||
let g:ale_set_signs = 1
|
||||
" Disable features we don't need for these tests.
|
||||
let g:ale_set_quickfix = 0
|
||||
let g:ale_set_loclist = 0
|
||||
let g:ale_set_highlights = 0
|
||||
let g:ale_echo_cursor = 0
|
||||
|
||||
call ale#sign#Clear()
|
||||
|
||||
function! TestCallback(buffer, output)
|
||||
return [
|
||||
\ {'lnum': 1, 'text': 'foo', 'type': 'W'},
|
||||
\ {'lnum': 2, 'text': 'foo', 'type': 'E'},
|
||||
\]
|
||||
endfunction
|
||||
|
||||
function! CollectSigns()
|
||||
redir => l:output
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
silent exec 'sign place group=ale'
|
||||
else
|
||||
silent exec 'sign place'
|
||||
endif
|
||||
redir END
|
||||
|
||||
let l:actual_sign_list = []
|
||||
|
||||
for l:line in split(l:output, "\n")
|
||||
let l:match = matchlist(l:line, ale#sign#ParsePattern())
|
||||
|
||||
if len(l:match) > 0
|
||||
call add(l:actual_sign_list, [l:match[1], l:match[3]])
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:actual_sign_list
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('foobar', {
|
||||
\ 'name': 'testlinter',
|
||||
\ 'callback': 'TestCallback',
|
||||
\ 'executable': has('win32') ? 'cmd' : 'echo',
|
||||
\ 'command': has('win32') ? 'echo foo bar' : '/bin/sh -c ''echo foo bar''',
|
||||
\})
|
||||
|
||||
After:
|
||||
delfunction TestCallback
|
||||
delfunction CollectSigns
|
||||
|
||||
unlet! g:ale_run_synchronously_callbacks
|
||||
call ale#sign#Clear()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The signs should be updated after linting is done):
|
||||
ALELint
|
||||
call ale#test#FlushJobs()
|
||||
|
||||
AssertEqual [['1', 'ALEWarningSign'], ['2', 'ALEErrorSign']], CollectSigns()
|
@ -0,0 +1,68 @@
|
||||
Before:
|
||||
Save g:ale_change_sign_column_color
|
||||
Save &verbose
|
||||
|
||||
function! ParseHighlight(name) abort
|
||||
redir => l:output
|
||||
silent execute 'highlight ' . a:name
|
||||
redir end
|
||||
|
||||
return substitute(join(split(l:output)[2:]), ' Last set.*', '', '')
|
||||
endfunction
|
||||
|
||||
function! SetHighlight(name, syntax) abort
|
||||
let l:match = matchlist(a:syntax, '\vlinks to (.+)$')
|
||||
|
||||
if !empty(l:match)
|
||||
execute 'highlight link ' . a:name . ' ' . l:match[1]
|
||||
else
|
||||
execute 'highlight ' . a:name . ' ' a:syntax
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let g:sign_highlight = ParseHighlight('SignColumn')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
delfunction ParseHighlight
|
||||
call SetHighlight('SignColumn', g:sign_highlight)
|
||||
delfunction SetHighlight
|
||||
unlet! g:sign_highlight
|
||||
|
||||
call ale#sign#Clear()
|
||||
|
||||
Execute(The SignColumn highlight shouldn't be changed if the option is off):
|
||||
let g:ale_change_sign_column_color = 0
|
||||
let b:sign_highlight = ParseHighlight('SignColumn')
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\])
|
||||
AssertEqual b:sign_highlight, ParseHighlight('SignColumn')
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [])
|
||||
AssertEqual b:sign_highlight, ParseHighlight('SignColumn')
|
||||
|
||||
Execute(The SignColumn highlight should be set and reset):
|
||||
let g:ale_change_sign_column_color = 1
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\])
|
||||
AssertEqual 'links to ALESignColumnWithErrors', ParseHighlight('SignColumn')
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [])
|
||||
AssertEqual 'links to ALESignColumnWithoutErrors', ParseHighlight('SignColumn')
|
||||
|
||||
Execute(The SignColumn should be correctly parsed when verbose=1):
|
||||
set verbose=1
|
||||
highlight SignColumn ctermfg=246 ctermbg=7 guifg=#839496 guibg=Grey
|
||||
|
||||
call ale#sign#SetUpDefaultColumnWithoutErrorsHighlight()
|
||||
|
||||
AssertEqual
|
||||
\ has('nvim')
|
||||
\ ? 'ctermfg=246 ctermbg=7 guifg=#839496 guibg=Grey'
|
||||
\ : 'term=standout ctermfg=246 ctermbg=7 guifg=#839496 guibg=Grey',
|
||||
\ ParseHighlight('ALESignColumnWithoutErrors')
|
57
sources_non_forked/ale/test/sign/test_sign_limits.vader
Normal file
57
sources_non_forked/ale/test/sign/test_sign_limits.vader
Normal file
@ -0,0 +1,57 @@
|
||||
Before:
|
||||
Save g:ale_max_signs
|
||||
|
||||
let g:ale_max_signs = -1
|
||||
|
||||
function! SetNProblems(sign_count)
|
||||
let l:loclist = []
|
||||
let l:range = range(1, a:sign_count)
|
||||
call setline(1, l:range)
|
||||
|
||||
for l:index in l:range
|
||||
call add(l:loclist, {
|
||||
\ 'bufnr': bufnr(''),
|
||||
\ 'lnum': l:index,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'a',
|
||||
\})
|
||||
endfor
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), l:loclist)
|
||||
|
||||
return sort(map(ale#sign#FindCurrentSigns(bufnr(''))[1], 'v:val[0]'), 'n')
|
||||
endfunction
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! b:ale_max_signs
|
||||
|
||||
delfunction SetNProblems
|
||||
|
||||
call ale#sign#Clear()
|
||||
|
||||
Execute(There should be no limit on signs with negative numbers):
|
||||
AssertEqual range(1, 42), SetNProblems(42)
|
||||
|
||||
Execute(0 signs should be set when the max is 0):
|
||||
let g:ale_max_signs = 0
|
||||
|
||||
AssertEqual [], SetNProblems(42)
|
||||
|
||||
Execute(1 signs should be set when the max is 1):
|
||||
let g:ale_max_signs = 1
|
||||
|
||||
AssertEqual [1], SetNProblems(42)
|
||||
|
||||
Execute(10 signs should be set when the max is 10):
|
||||
let g:ale_max_signs = 10
|
||||
|
||||
" We'll check that we set signs for the first 10 items, not other lines.
|
||||
AssertEqual range(1, 10), SetNProblems(42)
|
||||
|
||||
Execute(5 signs should be set when the max is 5 for the buffer):
|
||||
let b:ale_max_signs = 5
|
||||
|
||||
AssertEqual range(1, 5), SetNProblems(42)
|
88
sources_non_forked/ale/test/sign/test_sign_parsing.vader
Normal file
88
sources_non_forked/ale/test/sign/test_sign_parsing.vader
Normal file
@ -0,0 +1,88 @@
|
||||
Execute (Parsing English signs should work):
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
AssertEqual
|
||||
\ [0, [[9, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([
|
||||
\ 'Signs for app.js:',
|
||||
\ ' line=9 id=1000001 group=ale name=ALEWarningSign',
|
||||
\ ])
|
||||
else
|
||||
AssertEqual
|
||||
\ [0, [[9, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([
|
||||
\ 'Signs for app.js:',
|
||||
\ ' line=9 id=1000001 name=ALEWarningSign',
|
||||
\ ])
|
||||
endif
|
||||
|
||||
Execute (Parsing Russian signs should work):
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
AssertEqual
|
||||
\ [0, [[1, 1000001, 'ALEErrorSign']]],
|
||||
\ ale#sign#ParseSigns([' строка=1 id=1000001 группа=ale имя=ALEErrorSign'])
|
||||
else
|
||||
AssertEqual
|
||||
\ [0, [[1, 1000001, 'ALEErrorSign']]],
|
||||
\ ale#sign#ParseSigns([' строка=1 id=1000001 имя=ALEErrorSign'])
|
||||
endif
|
||||
|
||||
Execute (Parsing Japanese signs should work):
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
AssertEqual
|
||||
\ [0, [[1, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([' 行=1 識別子=1000001 グループ=ale 名前=ALEWarningSign'])
|
||||
else
|
||||
AssertEqual
|
||||
\ [0, [[1, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([' 行=1 識別子=1000001 名前=ALEWarningSign'])
|
||||
endif
|
||||
|
||||
Execute (Parsing Spanish signs should work):
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
AssertEqual
|
||||
\ [0, [[12, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([' línea=12 id=1000001 grupo=ale nombre=ALEWarningSign'])
|
||||
else
|
||||
AssertEqual
|
||||
\ [0, [[12, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([' línea=12 id=1000001 nombre=ALEWarningSign'])
|
||||
endif
|
||||
|
||||
Execute (Parsing Italian signs should work):
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
AssertEqual
|
||||
\ [0, [[1, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([' riga=1 id=1000001, gruppo=ale nome=ALEWarningSign'])
|
||||
else
|
||||
AssertEqual
|
||||
\ [0, [[1, 1000001, 'ALEWarningSign']]],
|
||||
\ ale#sign#ParseSigns([' riga=1 id=1000001, nome=ALEWarningSign'])
|
||||
endif
|
||||
|
||||
Execute (Parsing German signs should work):
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
AssertEqual
|
||||
\ [0, [[235, 1000001, 'ALEErrorSign']]],
|
||||
\ ale#sign#ParseSigns([' Zeile=235 id=1000001 Gruppe=ale Name=ALEErrorSign'])
|
||||
else
|
||||
AssertEqual
|
||||
\ [0, [[235, 1000001, 'ALEErrorSign']]],
|
||||
\ ale#sign#ParseSigns([' Zeile=235 id=1000001 Name=ALEErrorSign'])
|
||||
endif
|
||||
|
||||
Execute (The sign parser should indicate if the dummy sign is set):
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
AssertEqual
|
||||
\ [1, [[1, 1000001, 'ALEErrorSign']]],
|
||||
\ ale#sign#ParseSigns([
|
||||
\ ' строка=1 id=1000001 group=ale имя=ALEErrorSign',
|
||||
\ ' line=1 id=1000000 group=ale name=ALEDummySign',
|
||||
\ ])
|
||||
else
|
||||
AssertEqual
|
||||
\ [1, [[1, 1000001, 'ALEErrorSign']]],
|
||||
\ ale#sign#ParseSigns([
|
||||
\ ' строка=1 id=1000001 имя=ALEErrorSign',
|
||||
\ ' line=1 id=1000000 name=ALEDummySign',
|
||||
\ ])
|
||||
endif
|
315
sources_non_forked/ale/test/sign/test_sign_placement.vader
Normal file
315
sources_non_forked/ale/test/sign/test_sign_placement.vader
Normal file
@ -0,0 +1,315 @@
|
||||
Before:
|
||||
Save g:ale_buffer_info
|
||||
Save g:ale_echo_cursor
|
||||
Save g:ale_run_synchronously
|
||||
Save g:ale_set_highlights
|
||||
Save g:ale_set_loclist
|
||||
Save g:ale_set_quickfix
|
||||
Save g:ale_set_signs
|
||||
Save g:ale_command_wrapper
|
||||
|
||||
let g:ale_command_wrapper = ''
|
||||
let g:ale_buffer_info = {}
|
||||
let g:ale_run_synchronously = 1
|
||||
let g:ale_set_signs = 1
|
||||
" Disable features we don't need for these tests.
|
||||
let g:ale_set_quickfix = 0
|
||||
let g:ale_set_loclist = 0
|
||||
let g:ale_set_highlights = 0
|
||||
let g:ale_echo_cursor = 0
|
||||
|
||||
call ale#linter#Reset()
|
||||
call ale#sign#Clear()
|
||||
|
||||
function! GenerateResults(buffer, output)
|
||||
return [
|
||||
\ {
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'foo',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'bar',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'baz',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 4,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'use this one',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 4,
|
||||
\ 'col': 2,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'ignore this one',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 5,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'ignore this one',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 5,
|
||||
\ 'col': 2,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'use this one',
|
||||
\ },
|
||||
\]
|
||||
endfunction
|
||||
|
||||
function! ParseSigns()
|
||||
redir => l:output
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
silent sign place group=ale
|
||||
else
|
||||
silent sign place
|
||||
endif
|
||||
redir END
|
||||
|
||||
return map(
|
||||
\ split(l:output, '\n')[2:],
|
||||
\ 'matchlist(v:val, ''' . ale#sign#ParsePattern() . ''')[1:3]',
|
||||
\)
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('testft', {
|
||||
\ 'name': 'x',
|
||||
\ 'executable': has('win32') ? 'cmd' : 'true',
|
||||
\ 'command': 'true',
|
||||
\ 'callback': 'GenerateResults',
|
||||
\})
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! g:ale_run_synchronously_callbacks
|
||||
unlet! g:loclist
|
||||
delfunction GenerateResults
|
||||
delfunction ParseSigns
|
||||
call ale#linter#Reset()
|
||||
call ale#sign#Clear()
|
||||
|
||||
Execute(ale#sign#GetSignName should return the right sign names):
|
||||
AssertEqual 'ALEErrorSign', ale#sign#GetSignName([{'type': 'E'}])
|
||||
AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignName([{'type': 'E', 'sub_type': 'style'}])
|
||||
AssertEqual 'ALEWarningSign', ale#sign#GetSignName([{'type': 'W'}])
|
||||
AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignName([{'type': 'W', 'sub_type': 'style'}])
|
||||
AssertEqual 'ALEInfoSign', ale#sign#GetSignName([{'type': 'I'}])
|
||||
AssertEqual 'ALEErrorSign', ale#sign#GetSignName([
|
||||
\ {'type': 'E'},
|
||||
\ {'type': 'W'},
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
AssertEqual 'ALEWarningSign', ale#sign#GetSignName([
|
||||
\ {'type': 'W'},
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
AssertEqual 'ALEInfoSign', ale#sign#GetSignName([
|
||||
\ {'type': 'I'},
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
AssertEqual 'ALEStyleErrorSign', ale#sign#GetSignName([
|
||||
\ {'type': 'E', 'sub_type': 'style'},
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
AssertEqual 'ALEStyleWarningSign', ale#sign#GetSignName([
|
||||
\ {'type': 'W', 'sub_type': 'style'},
|
||||
\])
|
||||
|
||||
Given testft(A file with warnings/errors):
|
||||
foo
|
||||
bar
|
||||
baz
|
||||
fourth line
|
||||
fifth line
|
||||
|
||||
Execute(The current signs should be set for running a job):
|
||||
ALELint
|
||||
call ale#test#FlushJobs()
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000001', 'ALEErrorSign'],
|
||||
\ ['2', '1000002', 'ALEWarningSign'],
|
||||
\ ['3', '1000003', 'ALEErrorSign'],
|
||||
\ ['4', '1000004', 'ALEErrorSign'],
|
||||
\ ['5', '1000005', 'ALEErrorSign'],
|
||||
\ ],
|
||||
\ ParseSigns()
|
||||
|
||||
Execute(Loclist items with sign_id values should be kept):
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000348 group=ale line=15 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000349 group=ale line=16 name=ALEWarningSign buffer=' . bufnr('')
|
||||
else
|
||||
exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000348 line=15 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000349 line=16 name=ALEWarningSign buffer=' . bufnr('')
|
||||
endif
|
||||
|
||||
let g:loclist = [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000349},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
|
||||
\]
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), g:loclist)
|
||||
|
||||
" Sign IDs from before should be kept, and new signs should use
|
||||
" IDs that haven't been used yet.
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000350},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000348},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000351},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000351},
|
||||
\ ],
|
||||
\ g:loclist
|
||||
|
||||
" Items should be grouped again. We should see error signs, where there
|
||||
" were warnings before, and errors where there were errors and where we
|
||||
" now have new warnings.
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['15', '1000348', 'ALEErrorSign'],
|
||||
\ ['16', '1000351', 'ALEErrorSign'],
|
||||
\ ['3', '1000347', 'ALEErrorSign'],
|
||||
\ ['4', '1000350', 'ALEWarningSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
Execute(Items for other buffers should be ignored):
|
||||
let g:loclist = [
|
||||
\ {'bufnr': bufnr('') - 1, 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a'},
|
||||
\ {'bufnr': bufnr('') - 1, 'lnum': 2, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000347},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
|
||||
\ {'bufnr': bufnr('') + 1, 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a'},
|
||||
\]
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), g:loclist)
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000001', 'ALEErrorSign'],
|
||||
\ ['15', '1000005', 'ALEWarningSign'],
|
||||
\ ['16', '1000006', 'ALEErrorSign'],
|
||||
\ ['2', '1000002', 'ALEWarningSign'],
|
||||
\ ['3', '1000003', 'ALEErrorSign'],
|
||||
\ ['4', '1000004', 'ALEWarningSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
Execute(Signs should be downgraded correctly):
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'x'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\])
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000001', 'ALEErrorSign'],
|
||||
\ ['2', '1000002', 'ALEWarningSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'I', 'text': 'x'},
|
||||
\])
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000003', 'ALEWarningSign'],
|
||||
\ ['2', '1000004', 'ALEInfoSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
Execute(Signs should be upgraded correctly):
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'I', 'text': 'x'},
|
||||
\])
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000001', 'ALEWarningSign'],
|
||||
\ ['2', '1000002', 'ALEInfoSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'E', 'text': 'x'},
|
||||
\ {'bufnr': bufnr(''), 'lnum': 2, 'col': 1, 'type': 'W', 'text': 'x'},
|
||||
\])
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['1', '1000003', 'ALEErrorSign'],
|
||||
\ ['2', '1000004', 'ALEWarningSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
Execute(It should be possible to clear signs with empty lists):
|
||||
let g:loclist = [
|
||||
\ {'bufnr': bufnr(''), 'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'},
|
||||
\]
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), g:loclist)
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ['16', '1000001', 'ALEErrorSign'],
|
||||
\ ],
|
||||
\ sort(ParseSigns())
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [])
|
||||
|
||||
AssertEqual [], ParseSigns()
|
||||
|
||||
Execute(No exceptions should be thrown when setting signs for invalid buffers):
|
||||
call ale#sign#SetSigns(123456789, [{'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}])
|
||||
|
||||
Execute(Signs should be removed when lines have multiple sign IDs on them):
|
||||
" We can fail to remove signs if there are multiple signs on one line,
|
||||
" say after deleting lines in Vim, etc.
|
||||
if has('nvim-0.4.2') || has('patch-8.1.614')
|
||||
exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000348 group=ale line=3 name=ALEWarningSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000349 group=ale line=10 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000350 group=ale line=10 name=ALEWarningSign buffer=' . bufnr('')
|
||||
else
|
||||
exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000348 line=3 name=ALEWarningSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000349 line=10 name=ALEErrorSign buffer=' . bufnr('')
|
||||
exec 'sign place 1000350 line=10 name=ALEWarningSign buffer=' . bufnr('')
|
||||
endif
|
||||
|
||||
call ale#sign#SetSigns(bufnr(''), [])
|
||||
AssertEqual [], ParseSigns()
|
Reference in New Issue
Block a user