mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 20:54:26 +08:00
Fix tests so they work with new NeoVim highlight code
This commit is contained in:
@@ -36,6 +36,7 @@ Before:
|
|||||||
\ 'ALEEvents',
|
\ 'ALEEvents',
|
||||||
\ 'ALEHighlightBufferGroup',
|
\ 'ALEHighlightBufferGroup',
|
||||||
\]
|
\]
|
||||||
|
let g:has_nvim_highlight = exists('*nvim_buf_add_highlight') && exists('*nvim_buf_clear_namespace')
|
||||||
|
|
||||||
function! ToggleTestCallback(buffer, output)
|
function! ToggleTestCallback(buffer, output)
|
||||||
return [{
|
return [{
|
||||||
@@ -91,6 +92,7 @@ After:
|
|||||||
unlet! g:expected_groups
|
unlet! g:expected_groups
|
||||||
unlet! b:ale_enabled
|
unlet! b:ale_enabled
|
||||||
unlet! g:output
|
unlet! g:output
|
||||||
|
unlet! g:has_nvim_highlight
|
||||||
|
|
||||||
call ale#linter#Reset()
|
call ale#linter#Reset()
|
||||||
|
|
||||||
@@ -120,9 +122,14 @@ Execute(ALEToggle should reset everything and then run again):
|
|||||||
" First check that everything is there...
|
" First check that everything is there...
|
||||||
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
||||||
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||||
AssertEqual
|
|
||||||
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
" Only check the legacy matches if not using the new NeoVIM API.
|
||||||
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
if !g:has_nvim_highlight
|
||||||
|
AssertEqual
|
||||||
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
||||||
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual g:expected_groups, ParseAuGroups()
|
AssertEqual g:expected_groups, ParseAuGroups()
|
||||||
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
||||||
|
|
||||||
@@ -133,7 +140,11 @@ Execute(ALEToggle should reset everything and then run again):
|
|||||||
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
||||||
AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared'
|
AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared'
|
||||||
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
||||||
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
|
||||||
|
if !g:has_nvim_highlight
|
||||||
|
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual g:expected_groups, ParseAuGroups()
|
AssertEqual g:expected_groups, ParseAuGroups()
|
||||||
|
|
||||||
" Toggle ALE on, everything should be set up and run again.
|
" Toggle ALE on, everything should be set up and run again.
|
||||||
@@ -142,9 +153,13 @@ Execute(ALEToggle should reset everything and then run again):
|
|||||||
|
|
||||||
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
||||||
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||||
AssertEqual
|
|
||||||
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
if !g:has_nvim_highlight
|
||||||
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
AssertEqual
|
||||||
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
||||||
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual g:expected_groups, ParseAuGroups()
|
AssertEqual g:expected_groups, ParseAuGroups()
|
||||||
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
||||||
|
|
||||||
@@ -228,9 +243,13 @@ Execute(ALEReset should reset everything for a buffer):
|
|||||||
" First check that everything is there...
|
" First check that everything is there...
|
||||||
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
||||||
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||||
AssertEqual
|
|
||||||
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
if !g:has_nvim_highlight
|
||||||
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
AssertEqual
|
||||||
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
||||||
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
||||||
|
|
||||||
" Now Toggle ALE off.
|
" Now Toggle ALE off.
|
||||||
@@ -241,7 +260,10 @@ Execute(ALEReset should reset everything for a buffer):
|
|||||||
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
||||||
AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared'
|
AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared'
|
||||||
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
||||||
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
|
||||||
|
if !g:has_nvim_highlight
|
||||||
|
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual 1, g:ale_enabled
|
AssertEqual 1, g:ale_enabled
|
||||||
|
|
||||||
@@ -254,9 +276,13 @@ Execute(ALEToggleBuffer should reset everything and then run again):
|
|||||||
" First check that everything is there...
|
" First check that everything is there...
|
||||||
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
||||||
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||||
AssertEqual
|
|
||||||
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
if !g:has_nvim_highlight
|
||||||
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
AssertEqual
|
||||||
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
||||||
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
||||||
|
|
||||||
" Now Toggle ALE off.
|
" Now Toggle ALE off.
|
||||||
@@ -266,7 +292,10 @@ Execute(ALEToggleBuffer should reset everything and then run again):
|
|||||||
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
||||||
AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared'
|
AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared'
|
||||||
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
||||||
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
|
||||||
|
if !g:has_nvim_highlight
|
||||||
|
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
||||||
|
endif
|
||||||
|
|
||||||
" Toggle ALE on, everything should be set up and run again.
|
" Toggle ALE on, everything should be set up and run again.
|
||||||
ALEToggleBuffer
|
ALEToggleBuffer
|
||||||
@@ -274,9 +303,13 @@ Execute(ALEToggleBuffer should reset everything and then run again):
|
|||||||
|
|
||||||
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
||||||
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||||
AssertEqual
|
|
||||||
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
if !g:has_nvim_highlight
|
||||||
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
AssertEqual
|
||||||
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
||||||
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual g:expected_groups, ParseAuGroups()
|
AssertEqual g:expected_groups, ParseAuGroups()
|
||||||
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
||||||
|
|
||||||
@@ -325,9 +358,13 @@ Execute(ALEResetBuffer should reset everything for a buffer):
|
|||||||
" First check that everything is there...
|
" First check that everything is there...
|
||||||
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
|
||||||
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
|
||||||
AssertEqual
|
|
||||||
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
if !g:has_nvim_highlight
|
||||||
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
AssertEqual
|
||||||
|
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
|
||||||
|
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
|
||||||
|
|
||||||
" Now Toggle ALE off.
|
" Now Toggle ALE off.
|
||||||
@@ -338,7 +375,10 @@ Execute(ALEResetBuffer should reset everything for a buffer):
|
|||||||
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
|
||||||
AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared'
|
AssertEqual [], ale#test#GetLoclistWithoutModule(), 'The loclist was not cleared'
|
||||||
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
|
||||||
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
|
||||||
|
if !g:has_nvim_highlight
|
||||||
|
AssertEqual [], getmatches(), 'The highlights were not cleared'
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual 1, g:ale_enabled
|
AssertEqual 1, g:ale_enabled
|
||||||
AssertEqual 1, get(b:, 'ale_enabled', 1)
|
AssertEqual 1, get(b:, 'ale_enabled', 1)
|
||||||
|
|||||||
@@ -146,9 +146,12 @@ Execute(Highlights set by ALE should be removed when buffer cleanup is done):
|
|||||||
\ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 2},
|
\ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 2},
|
||||||
\])
|
\])
|
||||||
|
|
||||||
AssertEqual
|
if !g:has_nvim_highlight
|
||||||
\ [{'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]}],
|
" This check doesn't work with the new API, for some reason.
|
||||||
\ GetMatchesWithoutIDs()
|
AssertEqual
|
||||||
|
\ [{'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]}],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
endif
|
||||||
|
|
||||||
call ale#engine#Cleanup(bufnr('%'))
|
call ale#engine#Cleanup(bufnr('%'))
|
||||||
|
|
||||||
@@ -189,31 +192,53 @@ Execute(Only ALE highlights should be restored when buffers are restored):
|
|||||||
call matchaddpos('SomeOtherGroup', [[1, 1, 1]])
|
call matchaddpos('SomeOtherGroup', [[1, 1, 1]])
|
||||||
|
|
||||||
" We should have both highlights.
|
" We should have both highlights.
|
||||||
AssertEqual
|
if g:has_nvim_highlight
|
||||||
\ [
|
" When the newer NeoVim API is used, we don't have to worry about
|
||||||
\ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]},
|
" other highlights, namespacing is available.
|
||||||
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
|
AssertEqual
|
||||||
\ ],
|
\ [
|
||||||
\ GetMatchesWithoutIDs()
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]},
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
else
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]},
|
||||||
|
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
|
||||||
|
\ ],
|
||||||
|
\ sort(GetMatchesWithoutIDs(), {m1, m2 -> m1.group < m2.group ? -1 : 1})
|
||||||
|
endif
|
||||||
|
|
||||||
call ale#highlight#BufferHidden(bufnr('%'))
|
call ale#highlight#BufferHidden(bufnr('%'))
|
||||||
|
|
||||||
" We should remove our highlight, but not the other one.
|
" We should remove our highlight, but not the other one.
|
||||||
AssertEqual
|
if g:has_nvim_highlight
|
||||||
\ [
|
AssertEqual [], GetMatchesWithoutIDs()
|
||||||
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]}
|
else
|
||||||
\ ],
|
AssertEqual
|
||||||
\ GetMatchesWithoutIDs()
|
\ [
|
||||||
|
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]}
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
endif
|
||||||
|
|
||||||
call ale#highlight#UpdateHighlights()
|
call ale#highlight#UpdateHighlights()
|
||||||
|
|
||||||
" Our highlight should apper again.
|
" Our highlight should apper again.
|
||||||
AssertEqual
|
if g:has_nvim_highlight
|
||||||
\ [
|
AssertEqual
|
||||||
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
|
\ [
|
||||||
\ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]},
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]},
|
||||||
\ ],
|
\ ],
|
||||||
\ GetMatchesWithoutIDs()
|
\ GetMatchesWithoutIDs()
|
||||||
|
else
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]},
|
||||||
|
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
|
||||||
|
\ ],
|
||||||
|
\ sort(GetMatchesWithoutIDs(), {m1, m2 -> m1.group < m2.group ? -1 : 1})
|
||||||
|
endif
|
||||||
|
|
||||||
Execute(Higlight end columns should set an appropriate size):
|
Execute(Higlight end columns should set an appropriate size):
|
||||||
call ale#highlight#SetHighlights(bufnr('%'), [
|
call ale#highlight#SetHighlights(bufnr('%'), [
|
||||||
@@ -260,32 +285,67 @@ Execute(Highlighting should support errors spanning many lines):
|
|||||||
|
|
||||||
call ale#highlight#SetHighlights(bufnr(''), g:items)
|
call ale#highlight#SetHighlights(bufnr(''), g:items)
|
||||||
|
|
||||||
" We should set 2 highlights for the item, as we can only add 8 at a time.
|
if g:has_nvim_highlight
|
||||||
AssertEqual
|
" The newer NeoVim highlight API produces different output.
|
||||||
\ [
|
AssertEqual
|
||||||
\ {
|
\ [
|
||||||
\ 'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1073741824],
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1073741824]},
|
||||||
\ 'pos2': [2], 'pos3': [3], 'pos4': [4], 'pos5': [5], 'pos6': [6],
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [2, 1, 1073741824]},
|
||||||
\ 'pos7': [7], 'pos8': [8],
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 1, 1073741824]},
|
||||||
\ },
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [4, 1, 1073741824]},
|
||||||
\ {
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [5, 1, 1073741824]},
|
||||||
\ 'group': 'ALEError', 'priority': 10,
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [6, 1, 1073741824]},
|
||||||
\ 'pos1': [9], 'pos2': [10, 1, 3]
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [7, 1, 1073741824]},
|
||||||
\ },
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [8, 1, 1073741824]},
|
||||||
\ ],
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [9, 1, 1073741824]},
|
||||||
\ GetMatchesWithoutIDs()
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [10, 1, 3]},
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
else
|
||||||
|
" We should set 2 highlights for the item, as we can only add 8 at a time.
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1073741824],
|
||||||
|
\ 'pos2': [2], 'pos3': [3], 'pos4': [4], 'pos5': [5], 'pos6': [6],
|
||||||
|
\ 'pos7': [7], 'pos8': [8],
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'group': 'ALEError', 'priority': 10,
|
||||||
|
\ 'pos1': [9], 'pos2': [10, 1, 3]
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
endif
|
||||||
|
|
||||||
Execute(Highlights should always be cleared when the buffer highlight list is empty):
|
Execute(Highlights should always be cleared when the buffer highlight list is empty):
|
||||||
" Add our highlights and something else.
|
if g:has_nvim_highlight
|
||||||
call matchaddpos('ALEError', [[1, 1, 1]])
|
" The newer API uses namespacing. We'll emulate it here.
|
||||||
call matchaddpos('SomeOtherGroup', [[1, 1, 1]])
|
call ale#highlight#nvim_buf_add_highlight(
|
||||||
|
\ bufnr(''),
|
||||||
|
\ 1,
|
||||||
|
\ 'ALEError',
|
||||||
|
\ 0,
|
||||||
|
\ 0,
|
||||||
|
\ 1,
|
||||||
|
\)
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [{'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]}],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
else
|
||||||
|
" Add our highlights and something else.
|
||||||
|
call matchaddpos('ALEError', [[1, 1, 1]])
|
||||||
|
call matchaddpos('SomeOtherGroup', [[1, 1, 1]])
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]},
|
||||||
|
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
endif
|
||||||
|
|
||||||
AssertEqual
|
|
||||||
\ [
|
|
||||||
\ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]},
|
|
||||||
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
|
|
||||||
\ ],
|
|
||||||
\ GetMatchesWithoutIDs()
|
|
||||||
|
|
||||||
" Set the List we use for holding highlights for buffers.
|
" Set the List we use for holding highlights for buffers.
|
||||||
let b:ale_highlight_items = []
|
let b:ale_highlight_items = []
|
||||||
@@ -295,11 +355,13 @@ Execute(Highlights should always be cleared when the buffer highlight list is em
|
|||||||
call ale#highlight#UpdateHighlights()
|
call ale#highlight#UpdateHighlights()
|
||||||
|
|
||||||
" Check that we remove our highlights.
|
" Check that we remove our highlights.
|
||||||
AssertEqual
|
if g:has_nvim_highlight
|
||||||
\ [
|
AssertEqual [], GetMatchesWithoutIDs()
|
||||||
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
|
else
|
||||||
\ ],
|
AssertEqual
|
||||||
\ GetMatchesWithoutIDs()
|
\ [{'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]}],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
endif
|
||||||
|
|
||||||
Execute(Highlights should be cleared when ALE is disabled):
|
Execute(Highlights should be cleared when ALE is disabled):
|
||||||
let g:ale_enabled = 1
|
let g:ale_enabled = 1
|
||||||
@@ -335,16 +397,30 @@ Execute(Line highlights should be set when signs are disabled):
|
|||||||
\ {'bufnr': bufnr(''), 'type': 'I', 'lnum': 3, 'col': 1},
|
\ {'bufnr': bufnr(''), 'type': 'I', 'lnum': 3, 'col': 1},
|
||||||
\])
|
\])
|
||||||
|
|
||||||
AssertEqual
|
if g:has_nvim_highlight
|
||||||
\ [
|
" The output is different with the newer NeoVIM highlight API.
|
||||||
\ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]},
|
AssertEqual
|
||||||
\ {'group': 'ALEWarning', 'priority': 10, 'pos1': [2, 1, 1]},
|
\ [
|
||||||
\ {'group': 'ALEInfo', 'priority': 10, 'pos1': [3, 1, 1]},
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]},
|
||||||
\ {'group': 'aleerrorline', 'priority': 10, 'pos1': [1]},
|
\ {'group': 'ALEErrorLine', 'priority': 10, 'pos1': [1, 1, 1073741824]},
|
||||||
\ {'group': 'ALEWarningLine', 'priority': 10, 'pos1': [2]},
|
\ {'group': 'ALEWarning', 'priority': 10, 'pos1': [2, 1, 1]},
|
||||||
\ {'group': 'ALEInfoLine', 'priority': 10, 'pos1': [3]},
|
\ {'group': 'ALEWarningLine', 'priority': 10, 'pos1': [2, 1, 1073741824]},
|
||||||
\ ],
|
\ {'group': 'ALEInfo', 'priority': 10, 'pos1': [3, 1, 1]},
|
||||||
\ GetMatchesWithoutIDs()
|
\ {'group': 'ALEInfoLine', 'priority': 10, 'pos1': [3, 1, 1073741824]}
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
else
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]},
|
||||||
|
\ {'group': 'ALEWarning', 'priority': 10, 'pos1': [2, 1, 1]},
|
||||||
|
\ {'group': 'ALEInfo', 'priority': 10, 'pos1': [3, 1, 1]},
|
||||||
|
\ {'group': 'aleerrorline', 'priority': 10, 'pos1': [1]},
|
||||||
|
\ {'group': 'ALEWarningLine', 'priority': 10, 'pos1': [2]},
|
||||||
|
\ {'group': 'ALEInfoLine', 'priority': 10, 'pos1': [3]},
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
endif
|
||||||
|
|
||||||
" All of the highlights should be removed.
|
" All of the highlights should be removed.
|
||||||
call ale#highlight#RemoveHighlights()
|
call ale#highlight#RemoveHighlights()
|
||||||
|
|||||||
Reference in New Issue
Block a user