Fix 4141 - Stop press enter prompt on long diagnostic messages (#4144)

* Fix 4141 - Stop press enter prompt on long diagnostic messages

* Fix 4139 - Check for array before join truncated_echo
This commit is contained in:
Horacio Sanson 2022-04-06 10:51:07 +09:00 committed by GitHub
parent cae550f07b
commit c984daa0ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 12 deletions

View File

@ -11,9 +11,9 @@ let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s')
let s:cursor_timer = -1
" A wrapper for echon so we can test messages we echo in Vader tests.
function! ale#cursor#Echon(message) abort
function! ale#cursor#Echom(message) abort
" no-custom-checks
echon a:message
exec "norm! :echom a:message\n"
endfunction
function! ale#cursor#TruncatedEcho(original_message) abort
@ -36,14 +36,7 @@ function! ale#cursor#TruncatedEcho(original_message) abort
silent! setlocal shortmess+=T
try
" echon will not display the message if it exceeds the width of
" the window
if &columns < strdisplaywidth(l:message)
" Truncate message longer than window width with trailing '...'
let l:message = l:message[:&columns - 5] . '...'
endif
call ale#cursor#Echon(l:message)
call ale#cursor#Echom(l:message)
catch /^Vim\%((\a\+)\)\=:E523/
" Fallback into manual truncate (#1987)
let l:winwidth = winwidth(0)

View File

@ -231,7 +231,11 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort
\&& (l:set_balloons is 1 || l:set_balloons is# 'hover')
call balloon_show(join(l:lines, "\n"))
elseif get(l:options, 'truncated_echo', 0)
call ale#cursor#TruncatedEcho(join(l:lines[0], '\n'))
if type(l:lines[0]) is# v:t_list
call ale#cursor#TruncatedEcho(join(l:lines[0], '\n'))
else
call ale#cursor#TruncatedEcho(l:lines[0])
endif
elseif g:ale_hover_to_floating_preview || g:ale_floating_preview
call ale#floating_preview#Show(l:lines, {
\ 'filetype': 'ale-preview.message',

View File

@ -89,7 +89,7 @@ Before:
let g:last_message = ''
function! ale#cursor#Echon(message) abort
function! ale#cursor#Echom(message) abort
let g:last_message = a:message
endfunction