From aabdd327903a74244c75b3c7cfcbd6e2bb10459a Mon Sep 17 00:00:00 2001 From: Jared Moulton Date: Sat, 31 Aug 2024 23:30:34 -0600 Subject: [PATCH] fix window pane capture (#120) --- src/cli.rs | 2 +- src/picker.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index bb3a0aa..7129123 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -303,7 +303,7 @@ fn windows_command(config: &Config, tmux: &Tmux) -> Result<()> { .map(|s| s.to_string()) .collect(); - if let Some(target_window) = get_single_selection(&windows, Preview::SessionPane, config, tmux)? + if let Some(target_window) = get_single_selection(&windows, Preview::WindowPane, config, tmux)? { if let Some((windex, _)) = target_window.split_once(' ') { tmux.select_window(windex); diff --git a/src/picker.rs b/src/picker.rs index bd63ebe..cb604a3 100644 --- a/src/picker.rs +++ b/src/picker.rs @@ -36,6 +36,7 @@ use crate::{ pub enum Preview { SessionPane, + WindowPane, None, Directory, } @@ -277,6 +278,12 @@ impl<'a> Picker<'a> { if let Some(item) = snapshot.get_matched_item(index as u32) { let output = match self.preview { Preview::SessionPane => self.tmux.capture_pane(item.data), + Preview::WindowPane => self.tmux.capture_pane( + item.data + .split_once(' ') + .map(|val| val.0) + .unwrap_or_default(), + ), Preview::Directory => process::Command::new("ls") .args(["-1", item.data]) .output()