Allow the cursor messages to be disabled while Vim is running

This commit is contained in:
w0rp 2017-12-19 14:43:18 +00:00
parent a7d51afda5
commit d2bea5c310
2 changed files with 19 additions and 0 deletions

View File

@ -55,6 +55,10 @@ function! ale#cursor#EchoCursorWarning(...) abort
endfunction endfunction
function! s:EchoImpl() abort function! s:EchoImpl() abort
if !g:ale_echo_cursor
return
endif
" Only echo the warnings in normal mode, otherwise we will get problems. " Only echo the warnings in normal mode, otherwise we will get problems.
if mode() isnot# 'n' if mode() isnot# 'n'
return return
@ -81,6 +85,10 @@ function! s:EchoImpl() abort
endfunction endfunction
function! ale#cursor#EchoCursorWarningWithDelay() abort function! ale#cursor#EchoCursorWarningWithDelay() abort
if !g:ale_echo_cursor
return
endif
" Only echo the warnings in normal mode, otherwise we will get problems. " Only echo the warnings in normal mode, otherwise we will get problems.
if mode() isnot# 'n' if mode() isnot# 'n'
return return

View File

@ -1,5 +1,6 @@
Before: Before:
Save g:ale_echo_msg_format Save g:ale_echo_msg_format
Save g:ale_echo_cursor
let g:ale_buffer_info = { let g:ale_buffer_info = {
\ bufnr('%'): { \ bufnr('%'): {
@ -66,6 +67,7 @@ Before:
let g:ale_set_loclist = 0 let g:ale_set_loclist = 0
let g:ale_set_signs = 0 let g:ale_set_signs = 0
let g:ale_set_highlights = 0 let g:ale_set_highlights = 0
let g:ale_echo_cursor = 1
function GetLastMessage() function GetLastMessage()
redir => l:output redir => l:output
@ -222,3 +224,12 @@ Execute(The buffer message format option should take precedence):
call ale#cursor#EchoCursorWarning() call ale#cursor#EchoCursorWarning()
AssertEqual 'FOO Some information', GetLastMessage() AssertEqual 'FOO Some information', GetLastMessage()
Execute(The cursor message shouldn't be echoed if the option is off):
let g:ale_echo_cursor = 0
echom 'foo'
call cursor(1, 1)
call ale#cursor#EchoCursorWarning()
AssertEqual 'foo', GetLastMessage()