All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 Save g:ale_virtualtext_cursor
4 Save g:ale_virtualtext_delay
5 Save g:ale_virtualtext_single
6 Save g:ale_virtualtext_prefix
7 Save b:ale_virtualtext_prefix
8 Save g:ale_use_neovim_diagnostics_api
10 call ale#virtualtext#ResetDataForTests()
13 let g:ale_virtualtext_prefix = '%comment% %type%: '
14 let g:ale_virtualtext_delay = 0
15 let g:ale_virtualtext_single = 0
16 let g:ale_buffer_info = {
24 \ 'text': 'Line 1 error',
31 \ 'text': 'Line 2 warning 1',
38 \ 'text': 'Line 2 warning 2',
45 \ 'text': 'Line 3 warning 1',
52 \ 'text': 'Line 3 error 1',
59 \ 'text': 'Line 3 error 2',
64 let g:ale_use_neovim_diagnostics_api = 0
72 Execute(The correct highlight groups should be loaded for virtual-text):
73 AssertEqual 'ALEVirtualTextError', ale#virtualtext#GetGroup({})
74 AssertEqual 'ALEVirtualTextError', ale#virtualtext#GetGroup({'type': 'E'})
75 AssertEqual 'ALEVirtualTextStyleError',
76 \ ale#virtualtext#GetGroup({'type': 'E', 'sub_type': 'style'})
77 AssertEqual 'ALEVirtualTextWarning', ale#virtualtext#GetGroup({'type': 'W'})
78 AssertEqual 'ALEVirtualTextStyleWarning',
79 \ ale#virtualtext#GetGroup({'type': 'W', 'sub_type': 'style'})
80 AssertEqual 'ALEVirtualTextInfo', ale#virtualtext#GetGroup({'type': 'I'})
82 Given python (An empty Python file):
83 Execute(Comment text should be detected correctly for Python files):
84 if has('patch-9.0.0297') || has('nvim-0.8.0')
85 AssertEqual '#', ale#virtualtext#GetComment(bufnr(''))
88 Given java (An empty Java file):
89 Execute(Comment text should be detected correctly for Java files):
90 if has('patch-9.0.0297') || has('nvim-0.8.0')
91 AssertEqual '//', ale#virtualtext#GetComment(bufnr(''))
94 Given html (An empty HTML file):
95 Execute(Comment text should be detected correctly for HTML files):
96 if has('patch-9.0.0297') || has('nvim-0.8.0')
97 AssertEqual "\<!--", ale#virtualtext#GetComment(bufnr(''))
100 Given python(An example Python file):
105 Execute(We should not show virtualtext when disabled):
106 if has('patch-9.0.0297') || has('nvim-0.8.0')
107 for g:setting in ['disabled', '0', 0]
108 call ale#virtualtext#ResetDataForTests()
110 let g:ale_virtualtext_cursor = g:setting
112 call ale#virtualtext#ShowCursorWarningWithDelay()
116 AssertEqual '', ale#virtualtext#GetLastMessageForTests()
120 Execute(We should find a virtualtext error on line 1):
121 if has('patch-9.0.0297') || has('nvim-0.8.0')
122 for g:setting in ['current', '1', 1]
123 call ale#virtualtext#ResetDataForTests()
125 let g:ale_virtualtext_cursor = 'current'
127 call ale#virtualtext#ShowCursorWarningWithDelay()
131 AssertEqual '# E: Line 1 error', ale#virtualtext#GetLastMessageForTests()
133 if has('patch-9.0.0297')
134 AssertEqual ['ALEVirtualTextError'], map(prop_list(1), {_, v -> v.type})
135 AssertEqual [], prop_list(2)
140 Execute(We should find a virtualtext error on line 2):
141 if has('patch-9.0.0297') || has('nvim-0.8.0')
142 let g:ale_virtualtext_cursor = 'current'
144 call ale#virtualtext#ShowCursorWarningWithDelay()
148 AssertEqual '# W: Line 2 warning 2', ale#virtualtext#GetLastMessageForTests()
150 if has('patch-9.0.0297')
151 AssertEqual [], prop_list(1)
152 AssertEqual ['ALEVirtualTextWarning'], map(prop_list(2), {_, v -> v.type})
156 Execute(We should be able to change the virtualtext prefix globally):
157 let g:ale_virtualtext_prefix = '%severity%: '
159 if has('patch-9.0.0297') || has('nvim-0.8.0')
160 let g:ale_virtualtext_cursor = 'current'
162 call ale#virtualtext#ShowCursorWarningWithDelay()
166 AssertEqual 'Error: Line 1 error', ale#virtualtext#GetLastMessageForTests()
169 Execute(We should be able to change the virtualtext prefix per-buffer):
170 let b:ale_virtualtext_prefix = 'B> '
172 if has('patch-9.0.0297') || has('nvim-0.8.0')
173 let g:ale_virtualtext_cursor = 'current'
175 call ale#virtualtext#ShowCursorWarningWithDelay()
179 AssertEqual 'B> Line 1 error', ale#virtualtext#GetLastMessageForTests()
182 Execute(We should be able to set messages across all lines):
183 if has('patch-9.0.0297') || has('nvim-0.8.0')
184 call ale#virtualtext#SetTexts(bufnr(''), g:ale_buffer_info[bufnr('')].loclist)
186 AssertEqual '# E: Line 3 error 2', ale#virtualtext#GetLastMessageForTests()
188 if has('patch-9.0.0297')
189 AssertEqual ['ALEVirtualTextError'], map(prop_list(1), {_, v -> v.type})
190 AssertEqual ['ALEVirtualTextWarning', 'ALEVirtualTextWarning'],
191 \ map(prop_list(2), {_, v -> v.type})
195 Execute(We should be able to limit virtual messages to the first one only):
196 let g:ale_virtualtext_single = 1
198 if has('patch-9.0.0297') || has('nvim-0.8.0')
199 call ale#virtualtext#SetTexts(bufnr(''), g:ale_buffer_info[bufnr('')].loclist)
201 AssertEqual '# E: Line 3 error 1', ale#virtualtext#GetLastMessageForTests()
203 if has('patch-9.0.0297')
204 AssertEqual ['ALEVirtualTextError'], map(prop_list(1), {_, v -> v.type})
205 AssertEqual ['ALEVirtualTextWarning'], map(prop_list(2), {_, v -> v.type})
206 AssertEqual ['ALEVirtualTextError'], map(prop_list(3), {_, v -> v.type})
210 Execute(We should not set cursor messages when Neovim diagnostics are enabled):
211 let g:ale_use_neovim_diagnostics_api = 1
213 if has('patch-9.0.0297') || has('nvim-0.8.0')
214 let g:ale_virtualtext_cursor = 'current'
216 call ale#virtualtext#ShowCursorWarningWithDelay()
220 AssertEqual '', ale#virtualtext#GetLastMessageForTests()