Fix #534 - Stop other higlights being restored when buffers are hidden and shown again
This commit is contained in:
parent
0ac82f0a17
commit
bf8aae02e8
2 changed files with 26 additions and 1 deletions
|
@ -97,7 +97,10 @@ endfunction
|
|||
|
||||
function! ale#highlight#BufferHidden(buffer) abort
|
||||
" Remember all matches, so they can be restored later.
|
||||
let s:buffer_restore_map[a:buffer] = getmatches()
|
||||
let s:buffer_restore_map[a:buffer] = filter(
|
||||
\ getmatches(),
|
||||
\ 'get(v:val, ''group'', '''')[:2] ==# ''ALE'''
|
||||
\)
|
||||
call clearmatches()
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -28,12 +28,14 @@ Before:
|
|||
\ 'command': 'echo',
|
||||
\ 'callback': 'GenerateResults',
|
||||
\})
|
||||
highlight link SomeOtherGroup SpellBad
|
||||
|
||||
After:
|
||||
delfunction GenerateResults
|
||||
call ale#linter#Reset()
|
||||
let g:ale_buffer_info = {}
|
||||
call clearmatches()
|
||||
highlight clear SomeOtherGroup
|
||||
|
||||
Given testft(A Javscript file with warnings/errors):
|
||||
foo
|
||||
|
@ -107,3 +109,23 @@ Execute(Highlights should be cleared when buffers are hidden):
|
|||
call ale#highlight#UpdateHighlights()
|
||||
|
||||
AssertEqual 1, len(getmatches()), 'The highlights weren''t set again!'
|
||||
|
||||
Execute(Only ALE highlights should be restored when buffers are restored):
|
||||
call ale#engine#InitBufferInfo(bufnr('%'))
|
||||
call ale#highlight#SetHighlights(bufnr('%'), [
|
||||
\ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 2},
|
||||
\])
|
||||
|
||||
call matchaddpos('SomeOtherGroup', [[1, 1, 1]])
|
||||
|
||||
" We should have one more match here.
|
||||
AssertEqual 2, len(getmatches()), 'The highlights weren''t initially set!'
|
||||
|
||||
call ale#highlight#BufferHidden(bufnr('%'))
|
||||
|
||||
AssertEqual 0, len(getmatches()), 'The highlights weren''t cleared!'
|
||||
|
||||
call ale#highlight#UpdateHighlights()
|
||||
|
||||
" Only our matches should appear again.
|
||||
AssertEqual 1, len(getmatches()), 'The highlights weren''t set again!'
|
||||
|
|
Reference in a new issue