From ceb2e8d350620366574c4c5efea66adfbeb0bb19 Mon Sep 17 00:00:00 2001 From: Linda_pp Date: Thu, 11 Oct 2018 23:01:27 +0900 Subject: Fix E523 on asynchronous truncated echo (#1987) --- autoload/ale/cursor.vim | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim index c3b48ca3..32ce8c84 100644 --- a/autoload/ale/cursor.vim +++ b/autoload/ale/cursor.vim @@ -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 -- cgit v1.2.3