mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-17 17:55:56 +08:00
Fix #1228 - Reset the cursor if echoing a message moves it
This commit is contained in:
@@ -15,9 +15,18 @@ function! ale#cursor#TruncatedEcho(original_message) abort
|
|||||||
let l:shortmess_options = &l:shortmess
|
let l:shortmess_options = &l:shortmess
|
||||||
|
|
||||||
try
|
try
|
||||||
|
let l:cursor_position = getcurpos()
|
||||||
|
|
||||||
" The message is truncated and saved to the history.
|
" The message is truncated and saved to the history.
|
||||||
setlocal shortmess+=T
|
setlocal shortmess+=T
|
||||||
exec "norm! :echomsg l:message\n"
|
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
|
finally
|
||||||
let &l:shortmess = l:shortmess_options
|
let &l:shortmess = l:shortmess_options
|
||||||
endtry
|
endtry
|
||||||
|
|||||||
Reference in New Issue
Block a user