Fix truncated echo (#3889)

* Fix truncated echo

In typescript, when putting the cursor on a `>` character of an arrow
function, the displayString body comes back as an empty string, and
means the split operation has 0 items, causing a failure when attempting
to call TruncatedEcho.

Even if there's a better fix, I'd assume this is a good safety since we
are injesting external data.

* Convert to use `empty()`
This commit is contained in:
Amadeus Demarzi 2021-09-05 19:26:32 -07:00 committed by GitHub
parent 8fd23f4b71
commit 35d0bd1519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -45,7 +45,9 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort
\&& (l:set_balloons is 1 || l:set_balloons is# 'hover')
call balloon_show(a:response.body.displayString)
elseif get(l:options, 'truncated_echo', 0)
call ale#cursor#TruncatedEcho(split(a:response.body.displayString, "\n")[0])
if !empty(a:response.body.displayString)
call ale#cursor#TruncatedEcho(split(a:response.body.displayString, "\n")[0])
endif
elseif g:ale_hover_to_floating_preview || g:ale_floating_preview
call ale#floating_preview#Show(split(a:response.body.displayString, "\n"), {
\ 'filetype': 'ale-preview.message',