commit af78060b188236cca9ef3479cbab94df56c89721
parent ec971288267dece8f1bc492847b3ae6e5271acd0
Author: Sean Dewar <seandewar@users.noreply.github.com>
Date: Mon, 21 Aug 2023 11:06:44 +0100
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.
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -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