From aa4c669ea00b8658150b5b15784e717b51762562 Mon Sep 17 00:00:00 2001 From: w0rp Date: Tue, 25 Oct 2016 16:07:20 +0100 Subject: #148 - Check the cursor position so we don't try to echo too frequently. --- autoload/ale/cursor.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'autoload') diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim index 7f490339..e9e678c6 100644 --- a/autoload/ale/cursor.vim +++ b/autoload/ale/cursor.vim @@ -64,6 +64,7 @@ function! ale#cursor#EchoCursorWarning(...) abort endfunction let s:cursor_timer = -1 +let s:last_pos = [0, 0, 0] function! ale#cursor#EchoCursorWarningWithDelay() abort if s:cursor_timer != -1 @@ -71,5 +72,14 @@ function! ale#cursor#EchoCursorWarningWithDelay() abort let s:cursor_timer = -1 endif - let s:cursor_timer = timer_start(10, function('ale#cursor#EchoCursorWarning')) + let l:pos = getcurpos()[0:2] + + " Check the current buffer, line, and column number against the last + " recorded position. If the position has actually changed, *then* + " we should echo something. Otherwise we can end up doing processing + " the echo message far too frequently. + if l:pos != s:last_pos + let s:last_pos = l:pos + let s:cursor_timer = timer_start(10, function('ale#cursor#EchoCursorWarning')) + endif endfunction -- cgit v1.2.3