summaryrefslogtreecommitdiff
path: root/test/sign/test_sign_column_highlighting.vader
blob: 4457a45c24df1dd35376f84428d97a68a77d95b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Before:
  Save g:ale_change_sign_column_color

  function! ParseHighlight(name) abort
    redir => l:output
      silent execute 'highlight ' . a:name
    redir end

    return join(split(l:output)[2:])
  endfunction

  function! SetHighlight(name, syntax) abort
    let l:match = matchlist(a:syntax, '\vlinks to (.+)$')

    if !empty(l:match)
      execute 'highlight link ' . a:name . ' ' . l:match[1]
    else
      execute 'highlight ' . a:name . ' ' a:syntax
    endif
  endfunction

  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):
  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#SetSigns(bufnr(''), [])
  AssertEqual 'links to ALESignColumnWithoutErrors', ParseHighlight('SignColumn')