summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-12-14 09:42:52 +0100
committerGitHub <noreply@github.com>2021-12-14 09:42:52 +0100
commit10da4348ae01d21f9003813d1a745772d4f6c32c (patch)
treeaf33f27687d363052f1b0c6700b105cdddc54119
parentd60e6625995a6e1bfcdfeb3d047c2c18e913e5b3 (diff)
Fix tab fullscreen switch (#941)
* fix(tab): switch focus with fullscreen * style(fmt): make rustfmt happy
-rw-r--r--zellij-server/src/tab.rs8
-rw-r--r--zellij-server/src/unit/screen_tests.rs35
2 files changed, 37 insertions, 6 deletions
diff --git a/zellij-server/src/tab.rs b/zellij-server/src/tab.rs
index a0386a456..ca8153ecf 100644
--- a/zellij-server/src/tab.rs
+++ b/zellij-server/src/tab.rs
@@ -129,7 +129,7 @@ pub(crate) struct Tab {
pub name: String,
panes: BTreeMap<PaneId, Box<dyn Pane>>,
pub panes_to_hide: HashSet<PaneId>,
- active_panes: HashMap<ClientId, PaneId>,
+ pub active_panes: HashMap<ClientId, PaneId>,
max_panes: Option<usize>,
viewport: Viewport, // includes all non-UI panes
display_area: Size, // includes all panes (including eg. the status bar and tab bar in the default layout)
@@ -507,6 +507,7 @@ impl Tab {
return;
}
pane_ids.sort(); // TODO: make this predictable
+ pane_ids.retain(|p| !self.panes_to_hide.contains(p));
let first_pane_id = pane_ids.get(0).unwrap();
self.connected_clients.insert(client_id);
self.active_panes.insert(client_id, *first_pane_id);
@@ -530,11 +531,6 @@ impl Tab {
self.add_client(client_id);
}
for (client_id, client_mode_info) in client_mode_infos {
- log::info!(
- "add_multiple_clients: client_id: {:?}, mode: {:?}",
- client_id,
- client_mode_info.mode
- );
self.mode_info.insert(client_id, client_mode_info);
}
}
diff --git a/zellij-server/src/unit/screen_tests.rs b/zellij-server/src/unit/screen_tests.rs
index d511e0a5d..cb2799580 100644
--- a/zellij-server/src/unit/screen_tests.rs
+++ b/zellij-server/src/unit/screen_tests.rs
@@ -438,3 +438,38 @@ pub fn toggle_to_previous_tab_delete() {
"Tab history is invalid"
);
}
+
+#[test]
+fn switch_to_tab_with_fullscreen() {
+ let size = Size {
+ cols: 121,
+ rows: 20,
+ };
+ let mut screen = create_new_screen(size);
+
+ new_tab(&mut screen, 1);
+ {
+ let active_tab = screen.get_active_tab_mut(1).unwrap();
+ active_tab.new_pane(PaneId::Terminal(2), Some(1));
+ active_tab.toggle_active_pane_fullscreen(1);
+ }
+ new_tab(&mut screen, 2);
+
+ screen.switch_tab_prev(1);
+
+ assert_eq!(
+ screen.get_active_tab(1).unwrap().position,
+ 0,
+ "Active tab switched to previous"
+ );
+ assert_eq!(
+ screen
+ .get_active_tab(1)
+ .unwrap()
+ .active_panes
+ .get(&1)
+ .unwrap(),
+ &PaneId::Terminal(2),
+ "Active pane is still the fullscreen pane"
+ );
+}