diff --git a/mux/src/tmux_commands.rs b/mux/src/tmux_commands.rs index c0761320575..c77d92e963b 100644 --- a/mux/src/tmux_commands.rs +++ b/mux/src/tmux_commands.rs @@ -172,6 +172,12 @@ impl TmuxDomainState { mux.add_tab_to_window(&tab, **gui_window_id)?; gui_window_id.notify(); + self.cmd_queue + .lock() + .unwrap() + .push_back(Box::new(CapturePane(pane.pane_id))); + TmuxDomainState::schedule_send_next_command(self.domain_id); + self.add_attached_pane(&pane, &tab.tab_id())?; log::info!("new pane attached"); } @@ -264,7 +270,7 @@ impl TmuxCommand for ListAllPanes { pub(crate) struct CapturePane(TmuxPaneId); impl TmuxCommand for CapturePane { fn get_command(&self) -> String { - format!("capturep -p -t {} -e -C\n", self.0) + format!("capturep -p -t %{} -e -C\n", self.0) } fn process_result(&self, domain_id: DomainId, result: &Guarded) -> anyhow::Result<()> { @@ -278,11 +284,14 @@ impl TmuxCommand for CapturePane { None => anyhow::bail!("Tmux domain lost"), }; + let unescaped = termwiz::tmux_cc::unvis(&result.output).context("unescape pane content")?; + let unescaped = unescaped.replace("\n", "\r\n"); + let pane_map = tmux_domain.inner.remote_panes.borrow(); if let Some(pane) = pane_map.get(&self.0) { let mut pane = pane.lock().expect("Grant lock of tmux cmd queue failed"); pane.output_write - .write_all(result.output.as_bytes()) + .write_all(unescaped.as_bytes()) .context("writing capture pane result to output")?; } diff --git a/termwiz/src/tmux_cc/mod.rs b/termwiz/src/tmux_cc/mod.rs index 218fa804035..4bce1457bd7 100644 --- a/termwiz/src/tmux_cc/mod.rs +++ b/termwiz/src/tmux_cc/mod.rs @@ -311,7 +311,7 @@ fn parse_line(line: &str) -> anyhow::Result { /// Decode OpenBSD `vis` encoded strings /// See: https://github.com/tmux/tmux/blob/486ce9b09855ae30a2bf5e576cb6f7ad37792699/compat/unvis.c -fn unvis(s: &str) -> anyhow::Result { +pub fn unvis(s: &str) -> anyhow::Result { enum State { Ground, Start,