Send lines one at a time

Previously the VtrSendLinesToRunner command was implemented by joining
the lines together with `\r` newline characters and then sending them
via a single batch `tmux send-keys` call. This caused some REPLs (pry
most notably) to display all the lines at once, and occasionally
mis-handle the sent text.

With this change, each line is now sent via a distinct `tmux send-keys`
call, better approximating a user interacting with the REPL.
This commit is contained in:
Chris Toomey 2021-01-25 19:55:28 -05:00 committed by Navid Sassan
parent 1f3d65e326
commit c762cdf21d

View File

@ -445,10 +445,11 @@ endfunction
function! s:SendTextToRunner(lines) function! s:SendTextToRunner(lines)
if !s:ValidRunnerPaneSet() | return | endif if !s:ValidRunnerPaneSet() | return | endif
let prepared = s:PrepareLines(a:lines) let prepared = s:PrepareLines(a:lines)
let joined_lines = join(prepared, "\r") . "\r"
let send_keys_cmd = s:TargetedTmuxCommand("send-keys", s:runner_pane) let send_keys_cmd = s:TargetedTmuxCommand("send-keys", s:runner_pane)
let targeted_cmd = send_keys_cmd . ' ' . shellescape(joined_lines) for line in prepared
let targeted_cmd = send_keys_cmd . ' ' . shellescape(line . "\r")
call s:SendTmuxCommand(targeted_cmd) call s:SendTmuxCommand(targeted_cmd)
endfor
endfunction endfunction
function! s:SendFileViaVtr(ensure_pane) function! s:SendFileViaVtr(ensure_pane)