diff --git a/reattachd/src/tmux/send.rs b/reattachd/src/tmux/send.rs index aefdb01..625d76d 100644 --- a/reattachd/src/tmux/send.rs +++ b/reattachd/src/tmux/send.rs @@ -1,7 +1,9 @@ -use std::process::Command; +use std::{process::Command, thread, time::Duration}; use crate::tmux::TmuxError; +const SUBMIT_DELAY: Duration = Duration::from_millis(100); + pub fn send_keys(target: &str, text: &str) -> Result<(), TmuxError> { let output = Command::new("tmux") .args(["send-keys", "-t", target, "-l", text]) @@ -13,6 +15,10 @@ pub fn send_keys(target: &str, text: &str) -> Result<(), TmuxError> { return Err(TmuxError::Command(stderr.to_string())); } + // Keep the submit key out of terminal applications' rapid-input/paste + // detection so that it is consistently handled as Enter. + thread::sleep(SUBMIT_DELAY); + let output = Command::new("tmux") .args(["send-keys", "-t", target, "Enter"]) .output()