Fix #1228 - Reset the cursor if echoing a message moves it

This commit is contained in:
w0rp 2017-12-19 12:06:08 +00:00
parent 91090f1af8
commit 2cacba5758
1 changed files with 9 additions and 0 deletions

View File

@ -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