mirror of
https://github.com/dense-analysis/ale
synced 2024-12-22 14:13:12 +00:00
Broken message in pycodestyle (or any other Linters whose name include 'code') (#3114)
* Swap substitution order for echoed message
This prevents 'code' string in liter_name to be substituted by accident.
Linters including pycodestyle have been affected by this problem.
* Add test for linter whose name contains 'code'
Test for c525db8cb4
This commit is contained in:
parent
198361bc0d
commit
93a13d7353
@ -258,9 +258,9 @@ function! ale#GetLocItemMessage(item, format_string) abort
|
||||
|
||||
" Replace special markers with certain information.
|
||||
" \=l:variable is used to avoid escaping issues.
|
||||
let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g')
|
||||
let l:msg = substitute(l:msg, '\V%severity%', '\=l:severity', 'g')
|
||||
let l:msg = substitute(l:msg, '\V%linter%', '\=l:linter_name', 'g')
|
||||
let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g')
|
||||
" Replace %s with the text.
|
||||
let l:msg = substitute(l:msg, '\V%s', '\=a:item.text', 'g')
|
||||
|
||||
|
@ -75,6 +75,17 @@ Before:
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'lowercase error',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 5,
|
||||
\ 'bufnr': bufnr('%'),
|
||||
\ 'vcol': 0,
|
||||
\ 'linter_name': 'fakecodelinter',
|
||||
\ 'nr': -1,
|
||||
\ 'type': 'E',
|
||||
\ 'code': 'E001',
|
||||
\ 'text': 'This error does not exist',
|
||||
\ },
|
||||
\ ],
|
||||
\ },
|
||||
\}
|
||||
@ -237,6 +248,14 @@ Execute(The %code% and %ifcode% should be removed when there's no code):
|
||||
|
||||
AssertEqual 'Some information', GetLastMessage()
|
||||
|
||||
Execute(The %code% should be formatted correctly when other variables contain 'code'):
|
||||
let g:ale_echo_msg_format = '%s (%linter%% code%)'
|
||||
|
||||
call cursor(3, 5)
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
|
||||
AssertEqual 'This error does not exist (fakecodelinter E001)', GetLastMessage()
|
||||
|
||||
Execute(The buffer message format option should take precedence):
|
||||
let g:ale_echo_msg_format = '%(code) %%s'
|
||||
let b:ale_echo_msg_format = 'FOO %s'
|
||||
|
Loading…
Reference in New Issue
Block a user