Fix #746 - Keep highlights from other plugins when buffers are hidden
This commit is contained in:
parent
6a84605c57
commit
82dd80c692
@ -669,7 +669,7 @@ function! ale#engine#Cleanup(buffer) abort
|
|||||||
|
|
||||||
if g:ale_set_highlights
|
if g:ale_set_highlights
|
||||||
call ale#highlight#UnqueueHighlights(a:buffer)
|
call ale#highlight#UnqueueHighlights(a:buffer)
|
||||||
call ale#highlight#RemoveHighlights([])
|
call ale#highlight#RemoveHighlights()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call remove(g:ale_buffer_info, a:buffer)
|
call remove(g:ale_buffer_info, a:buffer)
|
||||||
|
@ -69,7 +69,7 @@ endfunction
|
|||||||
|
|
||||||
" Given a loclist for current items to highlight, remove all highlights
|
" Given a loclist for current items to highlight, remove all highlights
|
||||||
" except these which have matching loclist item entries.
|
" except these which have matching loclist item entries.
|
||||||
function! ale#highlight#RemoveHighlights(loclist) abort
|
function! ale#highlight#RemoveHighlights() abort
|
||||||
for l:match in s:GetALEMatches()
|
for l:match in s:GetALEMatches()
|
||||||
call matchdelete(l:match.id)
|
call matchdelete(l:match.id)
|
||||||
endfor
|
endfor
|
||||||
@ -81,7 +81,7 @@ function! ale#highlight#UpdateHighlights() abort
|
|||||||
let l:loclist = l:has_new_items ? remove(s:buffer_highlights, l:buffer) : []
|
let l:loclist = l:has_new_items ? remove(s:buffer_highlights, l:buffer) : []
|
||||||
|
|
||||||
if l:has_new_items || !g:ale_enabled
|
if l:has_new_items || !g:ale_enabled
|
||||||
call ale#highlight#RemoveHighlights(l:loclist)
|
call ale#highlight#RemoveHighlights()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Restore items from the map of hidden items,
|
" Restore items from the map of hidden items,
|
||||||
@ -131,7 +131,7 @@ function! ale#highlight#BufferHidden(buffer) abort
|
|||||||
\ 'v:val.bufnr == a:buffer && v:val.col > 0'
|
\ 'v:val.bufnr == a:buffer && v:val.col > 0'
|
||||||
\)
|
\)
|
||||||
|
|
||||||
call clearmatches()
|
call ale#highlight#RemoveHighlights()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -120,17 +120,32 @@ 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 one more match here.
|
" We should have both highlights.
|
||||||
AssertEqual 2, len(GetMatchesWithoutIDs()), 'The highlights weren''t initially set!'
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]},
|
||||||
|
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
|
||||||
call ale#highlight#BufferHidden(bufnr('%'))
|
call ale#highlight#BufferHidden(bufnr('%'))
|
||||||
|
|
||||||
AssertEqual 0, len(GetMatchesWithoutIDs()), 'The highlights weren''t cleared!'
|
" We should remove our highlight, but not the other one.
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]}
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
|
||||||
call ale#highlight#UpdateHighlights()
|
call ale#highlight#UpdateHighlights()
|
||||||
|
|
||||||
" Only our matches should appear again.
|
" Our highlight should apper again.
|
||||||
AssertEqual 1, len(GetMatchesWithoutIDs()), 'The highlights weren''t set again!'
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
|
||||||
|
\ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]},
|
||||||
|
\ ],
|
||||||
|
\ GetMatchesWithoutIDs()
|
||||||
|
|
||||||
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('%'), [
|
||||||
|
Loading…
Reference in New Issue
Block a user