From d2bea5c3101e9f198492efb8ca294e63e62415a4 Mon Sep 17 00:00:00 2001 From: w0rp Date: Tue, 19 Dec 2017 14:43:18 +0000 Subject: [PATCH] Allow the cursor messages to be disabled while Vim is running --- autoload/ale/cursor.vim | 8 ++++++++ test/test_cursor_warnings.vader | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim index 25e91e7..50b1fb5 100644 --- a/autoload/ale/cursor.vim +++ b/autoload/ale/cursor.vim @@ -55,6 +55,10 @@ function! ale#cursor#EchoCursorWarning(...) abort endfunction function! s:EchoImpl() abort + if !g:ale_echo_cursor + return + endif + " Only echo the warnings in normal mode, otherwise we will get problems. if mode() isnot# 'n' return @@ -81,6 +85,10 @@ function! s:EchoImpl() abort endfunction function! ale#cursor#EchoCursorWarningWithDelay() abort + if !g:ale_echo_cursor + return + endif + " Only echo the warnings in normal mode, otherwise we will get problems. if mode() isnot# 'n' return diff --git a/test/test_cursor_warnings.vader b/test/test_cursor_warnings.vader index f112d8d..1959221 100644 --- a/test/test_cursor_warnings.vader +++ b/test/test_cursor_warnings.vader @@ -1,5 +1,6 @@ Before: Save g:ale_echo_msg_format + Save g:ale_echo_cursor let g:ale_buffer_info = { \ bufnr('%'): { @@ -66,6 +67,7 @@ Before: let g:ale_set_loclist = 0 let g:ale_set_signs = 0 let g:ale_set_highlights = 0 + let g:ale_echo_cursor = 1 function GetLastMessage() redir => l:output @@ -222,3 +224,12 @@ Execute(The buffer message format option should take precedence): call ale#cursor#EchoCursorWarning() 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()