-
-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing a tab causes pane focus to shift to the next tab #3303
Comments
Hey, the reproduction is a bit involved so it'll take me some time to get to it - but I want to give you a quick answer so I'm going to guess a little:
I hope one of these can help explain and work around your issue? |
Yeah, sorry about that, I wanted to provide a complete repro. The TLDR is that focusing a specific pane after removing a tab focuses the next pane (+1 from the expected one).
|
Hey @SecretPocketCat - I tried your reproduction and for me it seems to work as expected (again, the example is a bit involved - if I understand the expected behavior correctly - I remain focused on the same pane after closing the tab). To me this indicates this is likely some sort of race (either between events or between plugin instances, since this example has 4 of them open). Would you maybe like to try and troubleshoot this a little? Remove as many elements as possible and find a minimal reproduction? I'd recommend trying to debug print the various state events you get (from PaneInfo and TabInfo) between each command send to Zellij, to make 100% sure the state looks like you expect it to. Also, try running with just 1 plugin instance.
A client is the connected user to the session (eg. if you attach from two different terminal windows to the same session, there will be 2 different clients connected). |
I'm not sure I've explained the issue clearly. My usecase is storing a pane ID (e.g. for an editor pane) for each tab and then jumping to that pane by using My assumption was the pane IDs are stable, but that might not be the case and are shifted when the tab is closed? I revamped the repro to be simpler and use just 1 plugin instance: TemplateEach tab tails the zellij log. I'm not sure if the dir name changes, so don't forget to update it if it's different for you. Other than that, the first tab contains the plugin.
PluginThe plugin logs tab focus changes and the tab of the focused pane - the ID is fixed to illustrate the issue. use std::collections::BTreeMap;
use zellij_tile::prelude::*;
const FOCUSED_TERM_ID: u32 = 2;
#[derive(Default)]
struct PluginState {
focused_tab: Option<usize>,
}
register_plugin!(PluginState);
impl ZellijPlugin for PluginState {
fn load(&mut self, _configuration: BTreeMap<String, String>) {
request_permission(&[
PermissionType::ReadApplicationState,
PermissionType::ChangeApplicationState,
]);
subscribe(&[EventType::TabUpdate, EventType::PaneUpdate]);
}
fn update(&mut self, event: Event) -> bool {
match event {
Event::TabUpdate(tabs) => {
let prev = self.focused_tab.clone();
self.focused_tab = tabs
.iter()
.enumerate()
.find(|(_, t)| t.active)
.map(|(i, _)| i);
eprintln!("Tab update: [{prev:?}] => [{:?}]", self.focused_tab);
}
Event::PaneUpdate(PaneManifest { panes }) => {
let pane_tab = panes
.iter()
.flat_map(|(i, panes)| panes.iter().map(move |p| (i, p)))
.find(|(_, p)| p.id == FOCUSED_TERM_ID && !p.is_plugin)
.map(|(i, _)| i);
eprintln!("Pane update: pane is at tab [{pane_tab:?}]");
}
_ => unimplemented!("{event:?}"),
};
false
}
fn pipe(&mut self, pipe_message: PipeMessage) -> bool {
if pipe_message.name == "focus" {
focus_terminal_pane(FOCUSED_TERM_ID, false);
}
false
}
} Repro
Expected behaviourThe pane and in turn the
This works before closing tab Actual behaviourThe
|
2. Issues with the Zellij UI / behavior / crash
Issue description
Removing a tab causes pane focus to shift to the next tab
Minimal reproduction
alt-f
to focus the terminal pane in theTabby 3 - focused
tab (this is not needed, but it shows it still behaves as expected at this point)alt-d
to close theTabby 2 - closed
tabalt-f
which should focus the terminal pane in theTabby 3 - focused
tab again, but it focusesTabby 4
insteadPlugin
Template
Other relevant information
Happens with #3299 too.
Based on testing with a different plugin, the pane is focused, but it's immediately followed by the incorrect focus of the next pane.
The text was updated successfully, but these errors were encountered: