summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/sign.vim22
-rw-r--r--test/sign/test_sign_column_highlighting.vader26
2 files changed, 36 insertions, 12 deletions
diff --git a/autoload/ale/sign.vim b/autoload/ale/sign.vim
index 7ba83647..b8d781dc 100644
--- a/autoload/ale/sign.vim
+++ b/autoload/ale/sign.vim
@@ -184,16 +184,6 @@ function! s:GroupLoclistItems(buffer, loclist) abort
return l:grouped_items
endfunction
-function! ale#sign#SetSignColumnHighlight(has_problems) abort
- highlight clear SignColumn
-
- if a:has_problems
- highlight link SignColumn ALESignColumnWithErrors
- else
- highlight link SignColumn ALESignColumnWithoutErrors
- endif
-endfunction
-
function! s:UpdateLineNumbers(buffer, current_sign_list, loclist) abort
let l:line_map = {}
let l:line_numbers_changed = 0
@@ -347,7 +337,19 @@ function! ale#sign#SetSigns(buffer, loclist) abort
\ l:sign_map,
\)
+ " Change the sign column color if the option is on.
+ if g:ale_change_sign_column_color && !empty(a:loclist)
+ highlight clear SignColumn
+ highlight link SignColumn ALESignColumnWithErrors
+ endif
+
for l:command in l:command_list
silent! execute l:command
endfor
+
+ " Reset the sign column color when there are no more errors.
+ if g:ale_change_sign_column_color && empty(a:loclist)
+ highlight clear SignColumn
+ highlight link SignColumn ALESignColumnWithoutErrors
+ endif
endfunction
diff --git a/test/sign/test_sign_column_highlighting.vader b/test/sign/test_sign_column_highlighting.vader
index 882b03de..4457a45c 100644
--- a/test/sign/test_sign_column_highlighting.vader
+++ b/test/sign/test_sign_column_highlighting.vader
@@ -1,4 +1,6 @@
Before:
+ Save g:ale_change_sign_column_color
+
function! ParseHighlight(name) abort
redir => l:output
silent execute 'highlight ' . a:name
@@ -20,14 +22,34 @@ Before:
let g:sign_highlight = ParseHighlight('SignColumn')
After:
+ Restore
+
delfunction ParseHighlight
call SetHighlight('SignColumn', g:sign_highlight)
delfunction SetHighlight
unlet! g:sign_highlight
+ sign unplace *
+
+Execute(The SignColumn highlight shouldn't be changed if the option is off):
+ let g:ale_change_sign_column_color = 0
+ let b:sign_highlight = ParseHighlight('SignColumn')
+
+ call ale#sign#SetSigns(bufnr(''), [
+ \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
+ \])
+ AssertEqual b:sign_highlight, ParseHighlight('SignColumn')
+
+ call ale#sign#SetSigns(bufnr(''), [])
+ AssertEqual b:sign_highlight, ParseHighlight('SignColumn')
+
Execute(The SignColumn highlight should be set and reset):
- call ale#sign#SetSignColumnHighlight(1)
+ let g:ale_change_sign_column_color = 1
+
+ call ale#sign#SetSigns(bufnr(''), [
+ \ {'bufnr': bufnr(''), 'lnum': 1, 'col': 1, 'type': 'W', 'text': 'x'},
+ \])
AssertEqual 'links to ALESignColumnWithErrors', ParseHighlight('SignColumn')
- call ale#sign#SetSignColumnHighlight(0)
+ call ale#sign#SetSigns(bufnr(''), [])
AssertEqual 'links to ALESignColumnWithoutErrors', ParseHighlight('SignColumn')