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.
2 Save g:ale_echo_msg_format
4 Save b:ale_lint_on_insert_leave
6 let g:ale_echo_msg_format = '%code: %%s'
7 let b:ale_lint_on_insert_leave = 0
9 " We should prefer the error message at column 10 instead of the warning.
10 let g:ale_buffer_info = {
16 \ 'bufnr': bufnr('%'),
18 \ 'linter_name': 'bettercode',
22 \ 'text': 'Ignore me.',
27 \ 'bufnr': bufnr('%'),
29 \ 'linter_name': 'bettercode',
33 \ 'text': "Missing semicolon.\r",
34 \ 'detail': "Every statement should end with a semicolon\nsecond line",
39 \ 'bufnr': bufnr('%'),
41 \ 'linter_name': 'bettercode',
44 \ 'text': 'Some information',
49 \ 'bufnr': bufnr('%'),
51 \ 'linter_name': 'bettercode',
54 \ 'code': 'space-infix-ops',
55 \ 'text': 'Infix operators must be spaced.',
60 \ 'bufnr': bufnr('%'),
62 \ 'linter_name': 'bettercode',
66 \ 'text': 'Missing radix parameter',
71 \ 'bufnr': bufnr('%'),
73 \ 'linter_name': 'bettercode',
76 \ 'text': 'lowercase error',
82 " Turn off other features, we only care about this one feature in this test.
83 let g:ale_set_loclist = 0
84 let g:ale_set_signs = 0
85 let g:ale_set_highlights = 0
86 let g:ale_echo_cursor = 1
88 runtime autoload/ale/cursor.vim
90 let g:last_message = ''
92 function! ale#cursor#Echom(message) abort
93 let g:last_message = a:message
96 call ale#linter#Reset()
97 call ale#linter#PreventLoading('javascript')
102 unlet! g:last_message
104 runtime autoload/ale/cursor.vim
108 let g:ale_set_loclist = 1
109 let g:ale_set_signs = 1
110 let g:ale_set_highlights = 1
112 let g:ale_buffer_info = {}
115 unlet! b:ale_loclist_msg_format
117 " Clearing the messages breaks tests on NeoVim for some reason, but all
118 " we need to do for these tests is just make it so the last message isn't
119 " carried over between test cases.
122 " Close the preview window if it's open.
123 if &filetype is# 'ale-preview'
127 call ale#linter#Reset()
129 Given javascript(A Javscript file with warnings/errors):
131 var x = 5*2 + parseInt("10");
134 Execute(Messages should be shown for the correct lines):
136 call ale#cursor#EchoCursorWarning()
138 AssertEqual 'semi: Missing semicolon.', g:last_message
140 Execute(Messages should be shown for earlier columns):
142 call ale#cursor#EchoCursorWarning()
144 AssertEqual 'space-infix-ops: Infix operators must be spaced.', g:last_message
146 Execute(Messages should be shown for later columns):
148 call ale#cursor#EchoCursorWarning()
150 AssertEqual 'radix: Missing radix parameter', g:last_message
152 Execute(The message at the cursor should be shown when linting ends):
154 call ale#engine#SetResults(
156 \ g:ale_buffer_info[bufnr('%')].loclist,
159 AssertEqual 'semi: Missing semicolon.', g:last_message
161 Execute(The message at the cursor should be shown when leaving insert mode):
163 call feedkeys("i\<Esc>", 'tnix')
165 AssertEqual 'space-infix-ops: Infix operators must be spaced.', g:last_message
167 Execute(ALEDetail should print 'detail' attributes):
173 \ ['Every statement should end with a semicolon', 'second line'],
176 Execute(ALEDetail should print regular 'text' attributes):
181 " ALEDetail opens a window, so check the text in it.
183 \ ['Infix operators must be spaced.'],
186 Execute(ALEDetail should not capitlise cursor messages):
188 call ale#cursor#EchoCursorWarning()
190 AssertEqual 'lowercase error', g:last_message
192 Execute(The linter name should be formatted into the message correctly):
193 let g:ale_echo_msg_format = '%linter%: %s'
196 call ale#cursor#EchoCursorWarning()
199 \ 'bettercode: Infix operators must be spaced.',
202 Execute(The severity should be formatted into the message correctly):
203 let g:ale_echo_msg_format = '%severity%: %s'
206 call ale#cursor#EchoCursorWarning()
209 \ 'Warning: Infix operators must be spaced.',
213 call ale#cursor#EchoCursorWarning()
215 AssertEqual 'Error: Missing semicolon.', g:last_message
218 call ale#cursor#EchoCursorWarning()
220 AssertEqual 'Info: Some information', g:last_message
222 Execute(The type should be formatted into the message correctly):
223 let g:ale_echo_msg_format = '%type%: %s'
226 call ale#cursor#EchoCursorWarning()
229 \ 'W: Infix operators must be spaced.',
233 call ale#cursor#EchoCursorWarning()
235 AssertEqual 'E: Missing semicolon.', g:last_message
238 call ale#cursor#EchoCursorWarning()
240 AssertEqual 'I: Some information', g:last_message
242 Execute(The %code% and %ifcode% should show the code and some text):
243 let g:ale_echo_msg_format = '%(code) %%s'
246 call ale#cursor#EchoCursorWarning()
249 \ '(space-infix-ops) Infix operators must be spaced.',
252 Execute(The %code% and %ifcode% should be removed when there's no code):
253 let g:ale_echo_msg_format = '%(code) %%s'
256 call ale#cursor#EchoCursorWarning()
258 AssertEqual 'Some information', g:last_message
260 Execute(The buffer message format option should take precedence):
261 let g:ale_echo_msg_format = '%(code) %%s'
262 let b:ale_echo_msg_format = 'FOO %s'
265 call ale#cursor#EchoCursorWarning()
267 AssertEqual 'FOO Some information', g:last_message
269 Execute(The cursor message shouldn't be echoed if the option is off):
270 let g:ale_echo_cursor = 0
271 let g:last_message = 'foo'
274 call ale#cursor#EchoCursorWarning()
276 AssertEqual 'foo', g:last_message