summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-07-10 00:02:49 +0100
committerw0rp <devw0rp@gmail.com>2017-07-10 00:02:49 +0100
commit82dd80c692bed7d9bdf0b9664b9222f4afb98fe2 (patch)
tree333c4393a4a8333dd2568327b61aac572751d6cb
parent6a84605c578ea844a02e429edb38ff2986bc308b (diff)
downloadale-82dd80c692bed7d9bdf0b9664b9222f4afb98fe2.zip
Fix #746 - Keep highlights from other plugins when buffers are hidden
-rw-r--r--autoload/ale/engine.vim2
-rw-r--r--autoload/ale/highlight.vim6
-rw-r--r--test/test_highlight_placement.vader25
3 files changed, 24 insertions, 9 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 1b32dc85..616ee351 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -669,7 +669,7 @@ function! ale#engine#Cleanup(buffer) abort
if g:ale_set_highlights
call ale#highlight#UnqueueHighlights(a:buffer)
- call ale#highlight#RemoveHighlights([])
+ call ale#highlight#RemoveHighlights()
endif
call remove(g:ale_buffer_info, a:buffer)
diff --git a/autoload/ale/highlight.vim b/autoload/ale/highlight.vim
index b7255b53..b24fd82b 100644
--- a/autoload/ale/highlight.vim
+++ b/autoload/ale/highlight.vim
@@ -69,7 +69,7 @@ endfunction
" Given a loclist for current items to highlight, remove all highlights
" 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()
call matchdelete(l:match.id)
endfor
@@ -81,7 +81,7 @@ function! ale#highlight#UpdateHighlights() abort
let l:loclist = l:has_new_items ? remove(s:buffer_highlights, l:buffer) : []
if l:has_new_items || !g:ale_enabled
- call ale#highlight#RemoveHighlights(l:loclist)
+ call ale#highlight#RemoveHighlights()
endif
" 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'
\)
- call clearmatches()
+ call ale#highlight#RemoveHighlights()
endif
endfunction
diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader
index 3fa45ed2..2e6a0ce3 100644
--- a/test/test_highlight_placement.vader
+++ b/test/test_highlight_placement.vader
@@ -120,17 +120,32 @@ Execute(Only ALE highlights should be restored when buffers are restored):
call matchaddpos('SomeOtherGroup', [[1, 1, 1]])
- " We should have one more match here.
- AssertEqual 2, len(GetMatchesWithoutIDs()), 'The highlights weren''t initially set!'
+ " We should have both highlights.
+ AssertEqual
+ \ [
+ \ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]},
+ \ {'group': 'SomeOtherGroup', 'priority': 10, 'pos1': [1, 1, 1]},
+ \ ],
+ \ GetMatchesWithoutIDs()
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()
- " Only our matches should appear again.
- AssertEqual 1, len(GetMatchesWithoutIDs()), 'The highlights weren''t set again!'
+ " Our highlight should apper 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):
call ale#highlight#SetHighlights(bufnr('%'), [