Fix #373 - echo the cursor message after lint cycles or when leaving Insert mode
This commit is contained in:
parent
fab9e8f5ea
commit
0e50a7d278
@ -268,6 +268,12 @@ function! ale#engine#SetResults(buffer, loclist) abort
|
||||
if g:ale_set_highlights
|
||||
call ale#highlight#SetHighlights(a:buffer, a:loclist)
|
||||
endif
|
||||
|
||||
if g:ale_echo_cursor
|
||||
" Try and echo the warning now.
|
||||
" This will only do something meaningful if we're in normal mode.
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:SetExitCode(job, exit_code) abort
|
||||
|
@ -166,6 +166,10 @@ function! s:ALEInitAuGroups() abort
|
||||
autocmd!
|
||||
if g:ale_enabled && g:ale_echo_cursor
|
||||
autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay()
|
||||
" Look for a warning to echo as soon as we leave Insert mode.
|
||||
" The script's position variable used when moving the cursor will
|
||||
" not be changed here.
|
||||
autocmd InsertLeave * call ale#cursor#EchoCursorWarning()
|
||||
endif
|
||||
augroup END
|
||||
|
||||
|
@ -36,7 +36,16 @@ Before:
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Turn off other features, we only care about this one feature in this test.
|
||||
let g:ale_set_loclist = 0
|
||||
let g:ale_set_signs = 0
|
||||
let g:ale_set_highlights = 0
|
||||
|
||||
After:
|
||||
let g:ale_set_loclist = 1
|
||||
let g:ale_set_signs = 1
|
||||
let g:ale_set_highlights = 1
|
||||
|
||||
unlet! g:output
|
||||
unlet! g:lines
|
||||
let g:ale_buffer_info = {}
|
||||
@ -84,3 +93,33 @@ Then(Check the cursor output):
|
||||
let g:lines = split(g:output, "\n")
|
||||
|
||||
AssertEqual 'Missing radix parameter (radix)', g:lines[-1]
|
||||
|
||||
Execute(Set results for a lint cycle, with the cursor on line 1):
|
||||
:1
|
||||
call ale#engine#SetResults(
|
||||
\ bufnr('%'),
|
||||
\ g:ale_buffer_info[bufnr('%')].loclist,
|
||||
\)
|
||||
|
||||
Then(Check the cursor output):
|
||||
redir => g:output
|
||||
:mess
|
||||
redir END
|
||||
|
||||
let g:lines = split(g:output, "\n")
|
||||
|
||||
AssertEqual 'Missing semicolon. (semi)', g:lines[-1]
|
||||
|
||||
Execute(Simulate leaving insert mode on line 2):
|
||||
:2
|
||||
normal 16h
|
||||
doautocmd InsertLeave
|
||||
|
||||
Then(Check the cursor output):
|
||||
redir => g:output
|
||||
:mess
|
||||
redir END
|
||||
|
||||
let g:lines = split(g:output, "\n")
|
||||
|
||||
AssertEqual 'Infix operators must be spaced. (space-infix-ops)', g:lines[-1]
|
||||
|
Loading…
Reference in New Issue
Block a user