From 71e2330112b84afa19db359e8ceafb25dbe3a1e8 Mon Sep 17 00:00:00 2001 From: Dante Pippi <6619666+dantepippi@users.noreply.github.com> Date: Fri, 7 May 2021 00:01:57 -0300 Subject: [PATCH] Fixing bug related to plugin panes and sync mode When sync mode was enabled the input from a plugin pane was being incorrectly ignored. --- src/client/tab.rs | 25 +++++++++---------------- src/server/mod.rs | 8 ++++---- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/client/tab.rs b/src/client/tab.rs index ceb72c2a5a..c4dc34743a 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -607,23 +607,17 @@ impl Tab { } pub fn write_to_terminals_on_current_tab(&mut self, input_bytes: Vec) { let pane_ids = self.get_pane_ids(); - pane_ids.iter().for_each(|pane_id| match pane_id { - PaneId::Terminal(pid) => { - self.write_to_pane_id(input_bytes.clone(), *pid); - } - PaneId::Plugin(_) => {} + pane_ids.iter().for_each(|&pane_id| { + self.write_to_pane_id(input_bytes.clone(), pane_id); }); } - pub fn write_to_pane_id(&mut self, mut input_bytes: Vec, pid: RawFd) { - self.os_api - .write_to_tty_stdin(pid, &mut input_bytes) - .expect("failed to write to terminal"); - self.os_api.tcdrain(pid).expect("failed to drain terminal"); - } pub fn write_to_active_terminal(&mut self, input_bytes: Vec) { - match self.get_active_pane_id() { - Some(PaneId::Terminal(active_terminal_id)) => { - let active_terminal = self.get_active_pane().unwrap(); + self.write_to_pane_id(input_bytes, self.get_active_pane_id().unwrap()); + } + pub fn write_to_pane_id(&mut self, input_bytes: Vec, pane_id: PaneId) { + match pane_id { + PaneId::Terminal(active_terminal_id) => { + let active_terminal = self.panes.get(&pane_id).unwrap(); let mut adjusted_input = active_terminal.adjust_input_to_terminal(input_bytes); self.os_api .write_to_tty_stdin(active_terminal_id, &mut adjusted_input) @@ -632,14 +626,13 @@ impl Tab { .tcdrain(active_terminal_id) .expect("failed to drain terminal"); } - Some(PaneId::Plugin(pid)) => { + PaneId::Plugin(pid) => { for key in parse_keys(&input_bytes) { self.send_plugin_instructions .send(PluginInstruction::Update(Some(pid), Event::KeyPress(key))) .unwrap() } } - _ => {} } } pub fn get_active_terminal_cursor_position(&self) -> Option<(usize, usize)> { diff --git a/src/server/mod.rs b/src/server/mod.rs index 6eb2455b2f..baeb0c62ec 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -528,11 +528,11 @@ fn init_session( ScreenInstruction::ChangeMode(mode_info) => { screen.change_mode(mode_info); } - ScreenInstruction::ToggleActiveSyncPanes => { + ScreenInstruction::ToggleActiveSyncTab => { screen .get_active_tab_mut() .unwrap() - .toggle_sync_panes_is_active(); + .toggle_sync_tab_is_active(); screen.update_tabs(); } ScreenInstruction::Exit => { @@ -781,10 +781,10 @@ fn route_action(action: Action, session: &SessionMetaData, os_input: &dyn Server .send(ScreenInstruction::SwitchTabPrev) .unwrap(); } - Action::ToggleActiveSyncPanes => { + Action::ToggleActiveSyncTab => { session .send_screen_instructions - .send(ScreenInstruction::ToggleActiveSyncPanes) + .send(ScreenInstruction::ToggleActiveSyncTab) .unwrap(); } Action::CloseTab => {