#604 Change match_id to match_id_list, for future highlights spanning more than 8 lines
This commit is contained in:
parent
e72dc1acd5
commit
fd49f7df90
@ -55,9 +55,9 @@ function! s:GetCurrentMatchIDs(loclist) abort
|
|||||||
let l:current_id_map = {}
|
let l:current_id_map = {}
|
||||||
|
|
||||||
for l:item in a:loclist
|
for l:item in a:loclist
|
||||||
if has_key(l:item, 'match_id')
|
for l:id in get(l:item, 'match_id_list', [])
|
||||||
let l:current_id_map[l:item.match_id] = 1
|
let l:current_id_map[l:id] = 1
|
||||||
endif
|
endfor
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return l:current_id_map
|
return l:current_id_map
|
||||||
@ -85,7 +85,7 @@ function! ale#highlight#UpdateHighlights() abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Remove anything with a current match_id
|
" Remove anything with a current match_id
|
||||||
call filter(l:loclist, '!has_key(v:val, ''match_id'')')
|
call filter(l:loclist, '!has_key(v:val, ''match_id_list'')')
|
||||||
|
|
||||||
" Restore items from the map of hidden items,
|
" Restore items from the map of hidden items,
|
||||||
" if we don't have some new items to set already.
|
" if we don't have some new items to set already.
|
||||||
@ -117,7 +117,7 @@ function! ale#highlight#UpdateHighlights() abort
|
|||||||
" Rememeber the match ID for the item.
|
" Rememeber the match ID for the item.
|
||||||
" This ID will be used to preserve loclist items which are set
|
" This ID will be used to preserve loclist items which are set
|
||||||
" many times.
|
" many times.
|
||||||
let l:item.match_id = matchaddpos(l:group, [[l:line, l:col, l:size]])
|
let l:item.match_id_list = [matchaddpos(l:group, [[l:line, l:col, l:size]])]
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -130,8 +130,8 @@ function! ale#highlight#BufferHidden(buffer) abort
|
|||||||
" Remove match_ids, as they must be re-calculated when buffers are
|
" Remove match_ids, as they must be re-calculated when buffers are
|
||||||
" shown again.
|
" shown again.
|
||||||
for l:item in l:loclist
|
for l:item in l:loclist
|
||||||
if has_key(l:item, 'match_id')
|
if has_key(l:item, 'match_id_list')
|
||||||
call remove(l:item, 'match_id')
|
call remove(l:item, 'match_id_list')
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
@ -55,15 +55,15 @@ Execute(Highlights should be set when a linter runs):
|
|||||||
\ ],
|
\ ],
|
||||||
\ getmatches()
|
\ getmatches()
|
||||||
|
|
||||||
AssertEqual [4, 5, 6], map(copy(g:ale_buffer_info[bufnr('')].loclist), 'v:val.match_id')
|
AssertEqual [[4], [5], [6]], map(copy(g:ale_buffer_info[bufnr('')].loclist), 'v:val.match_id_list')
|
||||||
|
|
||||||
Execute(Existing highlights should be kept):
|
Execute(Existing highlights should be kept):
|
||||||
call matchaddpos('ALEError', [[1, 2, 1]], 10, 347)
|
call matchaddpos('ALEError', [[1, 2, 1]], 10, 347)
|
||||||
call matchaddpos('ALEWarning', [[2, 2, 1]], 10, 348)
|
call matchaddpos('ALEWarning', [[2, 2, 1]], 10, 348)
|
||||||
|
|
||||||
call ale#highlight#SetHighlights(bufnr('%'), [
|
call ale#highlight#SetHighlights(bufnr('%'), [
|
||||||
\ {'bufnr': bufnr('%'), 'match_id': 347, 'type': 'E', 'lnum': 1, 'col': 2},
|
\ {'bufnr': bufnr('%'), 'match_id_list': [347], 'type': 'E', 'lnum': 1, 'col': 2},
|
||||||
\ {'bufnr': bufnr('%'), 'match_id': 348, 'type': 'W', 'lnum': 2, 'col': 2},
|
\ {'bufnr': bufnr('%'), 'match_id_list': [348], 'type': 'W', 'lnum': 2, 'col': 2},
|
||||||
\ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 2},
|
\ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 2},
|
||||||
\ {'bufnr': bufnr('%'), 'type': 'W', 'lnum': 4, 'col': 1},
|
\ {'bufnr': bufnr('%'), 'type': 'W', 'lnum': 4, 'col': 1},
|
||||||
\])
|
\])
|
||||||
|
@ -66,7 +66,7 @@ Execute(The loclist should be updated after linting is done):
|
|||||||
|
|
||||||
AssertEqual ['' . bufnr('%')], keys(g:ale_buffer_info)
|
AssertEqual ['' . bufnr('%')], keys(g:ale_buffer_info)
|
||||||
|
|
||||||
let g:expected_data[0].match_id = getmatches()[0].id
|
let g:expected_data[0].match_id_list = [getmatches()[0].id]
|
||||||
let g:expected_data[1].match_id = getmatches()[1].id
|
let g:expected_data[1].match_id_list = [getmatches()[1].id]
|
||||||
|
|
||||||
AssertEqual g:expected_data, g:ale_buffer_info[bufnr('%')].loclist
|
AssertEqual g:expected_data, g:ale_buffer_info[bufnr('%')].loclist
|
||||||
|
Loading…
Reference in New Issue
Block a user