zellij
zellij copied to clipboard
[BUG] Zellij forgets focused tab when attaching to a running session
Basic information
zellij --version: 0.36
stty size: 63 238
uname -av or ver(Windows): Darwin utkarsh-mbp 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64
List of programs you interact with as, PROGRAM --version: output cropped meaningful, for example:
nvim --version: v0.9.0
alacritty --version: 0.12
Further information
When attaching an existing session (zellij -l nvim a -c nvim), the focused tab is forgotten & Zellij starts at the first tab. This can be pretty annoying when switching a lot.
I can raise a PR if pointed in the right direction.
This bothers me too. Did some digging. Here is what I found out:
On detach there is a call to remove_client function which clears out active_tab_indices
https://github.com/zellij-org/zellij/blob/df0c7f1d9a911a36205685975dd29b1cd17c7299/zellij-server/src/screen.rs#L1190-L1192
When attaching later to the session add_client function selects 0's tab index because active_tab_indices is empty
https://github.com/zellij-org/zellij/blob/df0c7f1d9a911a36205685975dd29b1cd17c7299/zellij-server/src/screen.rs#L1159-L1169
Since I'm not familiar with the codebase I'm not sure what is correct fix should be here. Maybe not removing the last client from active_tab_indices will suffice, i.e:
if self.active_tab_indices.len() > 1 {
self.active_tab_indices.remove(&client_id);
}
Yep, that solves it. You wanna raise a PR?
@utkarshgupta137 I'd like to wait to hear from maintainers but if you want to make a PR and continue discussion there, please go for it.