From 2cacba5758614beadee38e493df957206aae8dde Mon Sep 17 00:00:00 2001 From: w0rp Date: Tue, 19 Dec 2017 12:06:08 +0000 Subject: [PATCH] Fix #1228 - Reset the cursor if echoing a message moves it --- autoload/ale/cursor.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim index 68dab75..25e91e7 100644 --- a/autoload/ale/cursor.vim +++ b/autoload/ale/cursor.vim @@ -15,9 +15,18 @@ function! ale#cursor#TruncatedEcho(original_message) abort let l:shortmess_options = &l:shortmess try + let l:cursor_position = getcurpos() + " The message is truncated and saved to the history. setlocal shortmess+=T exec "norm! :echomsg l:message\n" + + " Reset the cursor position if we moved off the end of the line. + " Using :norm and :echomsg can move the cursor off the end of the + " line. + if l:cursor_position != getcurpos() + call setpos('.', l:cursor_position) + endif finally let &l:shortmess = l:shortmess_options endtry