Skip to content

Commit 8cff748

Browse files
committed
feat(zellij-server): restore tab position when re-attaching
1 parent 717e54e commit 8cff748

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

zellij-server/src/screen.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ pub(crate) struct Screen {
692692
connected_clients: Rc<RefCell<HashSet<ClientId>>>,
693693
/// The indices of this [`Screen`]'s active [`Tab`]s.
694694
active_tab_indices: BTreeMap<ClientId, usize>,
695+
global_last_active_tab_index: usize,
695696
tab_history: BTreeMap<ClientId, Vec<usize>>,
696697
mode_info: BTreeMap<ClientId, ModeInfo>,
697698
default_mode_info: ModeInfo, // TODO: restructure ModeInfo to prevent this duplication
@@ -764,6 +765,7 @@ impl Screen {
764765
style: client_attributes.style,
765766
connected_clients: Rc::new(RefCell::new(HashSet::new())),
766767
active_tab_indices: BTreeMap::new(),
768+
global_last_active_tab_index: 0,
767769
tabs: BTreeMap::new(),
768770
overlay: OverlayWindow::default(),
769771
terminal_emulator_colors: Rc::new(RefCell::new(Palette::default())),
@@ -1523,6 +1525,8 @@ impl Screen {
15231525
self.active_tab_indices.iter().next()
15241526
{
15251527
*first_active_tab_index
1528+
} else if self.tabs.contains_key(&self.global_last_active_tab_index) {
1529+
self.global_last_active_tab_index
15261530
} else if self.tabs.contains_key(&0) {
15271531
0
15281532
} else if let Some(tab_index) = self.tabs.keys().next() {
@@ -1551,6 +1555,7 @@ impl Screen {
15511555
}
15521556
}
15531557
if self.active_tab_indices.contains_key(&client_id) {
1558+
self.global_last_active_tab_index = *self.active_tab_indices.get(&client_id).unwrap();
15541559
self.active_tab_indices.remove(&client_id);
15551560
}
15561561
if self.tab_history.contains_key(&client_id) {

0 commit comments

Comments
 (0)