fix(termdebug): trim suffixed "\r" in CommOutput

Vim splits lines on "\r", then trims any prefixed "\n".

But in Nvim, job output lines are split on "\n" (like readfile() in binary
mode), so trim any suffixed "\r" instead.

This gets rid of the trailing "^M" character in messages parsed from the jobs.
This commit is contained in:
Sean Dewar 2023-08-21 11:06:44 +01:00
parent ec97128826
commit af78060b18
No known key found for this signature in database
GPG Key ID: 08CC2C83AD41B581

View File

@ -875,7 +875,9 @@ func s:HandleDisasmMsg(msg)
else
let value = substitute(a:msg, '^\~\"[ ]*', '', '')
let value = substitute(value, '^=>[ ]*', '', '')
let value = substitute(value, '\\n\"\r$', '', '')
" Nvim already trims the final "\r" in s:CommOutput()
" let value = substitute(value, '\\n\"\r$', '', '')
let value = substitute(value, '\\n\"$', '', '')
let value = substitute(value, '\r', '', '')
let value = substitute(value, '\\t', ' ', 'g')
@ -929,11 +931,10 @@ func s:HandleVariablesMsg(msg)
endfunc
func s:CommOutput(job_id, msgs, event)
for msg in a:msgs
" remove prefixed NL
if msg[0] == "\n"
let msg = msg[1:]
" Nvim job lines are split on "\n", so trim a suffixed CR.
if msg[-1:] == "\r"
let msg = msg[:-2]
endif
if s:parsing_disasm_msg