Fix E523 on asynchronous truncated echo (#1987)

This commit is contained in:
Linda_pp 2018-10-11 23:01:27 +09:00 committed by w0rp
parent 96d84aec8f
commit ceb2e8d350
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
1 changed files with 14 additions and 1 deletions

View File

@ -26,7 +26,20 @@ function! ale#cursor#TruncatedEcho(original_message) abort
" The message is truncated and saved to the history.
setlocal shortmess+=T
exec "norm! :echomsg l:message\n"
try
exec "norm! :echomsg l:message\n"
catch /^Vim\%((\a\+)\)\=:E523/
" Fallback into manual truncate (#1987)
let l:winwidth = winwidth(0)
if l:winwidth < strdisplaywidth(l:message)
" Truncate message longer than window width with trailing '...'
let l:message = l:message[:l:winwidth - 4] . '...'
endif
exec 'echomsg l:message'
endtry
" 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