summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-06-12 22:05:32 +0200
committerGitHub <noreply@github.com>2023-06-12 22:05:32 +0200
commitc65017c7669725a285713dc3063108bcaa2317ce (patch)
treefa6406c9508dd813556f0f6d511b2ee3d13b7b93
parent02ee810d82323a83f5ffb2f6b36921e783a4d764 (diff)
fix(screen): focus tab as well as pane when launching existing plugin (#2530)
* fix(screen): focus tab as well as pane when launching existing plugin * style(fmt): rustfmt
-rw-r--r--zellij-server/src/screen.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index de53d0276..c81e23955 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -1472,15 +1472,27 @@ impl Screen {
client_id: ClientId,
) -> Result<bool> {
// true => found and focused, false => not
+ let err_context = || format!("failed to focus_plugin_pane");
+ let mut tab_index_and_plugin_pane_id = None;
let all_tabs = self.get_tabs_mut();
- for tab in all_tabs.values_mut() {
+ for (tab_index, tab) in all_tabs.iter_mut() {
if let Some(plugin_pane_id) = tab.find_plugin(&run_plugin) {
- tab.focus_pane_with_id(plugin_pane_id, should_float, client_id)
- .context("failed to focus plugin pane")?;
- return Ok(true);
+ tab_index_and_plugin_pane_id = Some((*tab_index, plugin_pane_id));
+ break;
}
}
- Ok(false)
+ match tab_index_and_plugin_pane_id {
+ Some((tab_index, plugin_pane_id)) => {
+ self.go_to_tab(tab_index + 1, client_id)?;
+ self.tabs
+ .get_mut(&tab_index)
+ .with_context(err_context)?
+ .focus_pane_with_id(plugin_pane_id, should_float, client_id)
+ .context("failed to focus plugin pane")?;
+ Ok(true)
+ },
+ None => Ok(false),
+ }
}
fn unblock_input(&self) -> Result<()> {