aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2025-07-21 14:58:00 +0200
committerGitHub <noreply@github.com>2025-07-21 14:58:00 +0200
commitba680fc2eb1b9bcc561eaf4bf5802b509dc1d9f2 (patch)
tree9dcc29dfd988bbf7c53026fa130dc652052b03c4
parentfix(plugins): standardize should_focus parameter when launching new plugin vi... (diff)
downloadsl0ppij-ba680fc2eb1b9bcc561eaf4bf5802b509dc1d9f2.tar.gz
sl0ppij-ba680fc2eb1b9bcc561eaf4bf5802b509dc1d9f2.tar.xz
sl0ppij-ba680fc2eb1b9bcc561eaf4bf5802b509dc1d9f2.zip
fix(compact-bar): tooltip duplication (#4310)
* fix(tooltip): update config name and only launch once * add new stacked pane to tooltip
-rw-r--r--default-plugins/compact-bar/src/action_types.rs3
-rw-r--r--default-plugins/compact-bar/src/keybind_utils.rs2
-rw-r--r--default-plugins/compact-bar/src/main.rs24
3 files changed, 26 insertions, 3 deletions
diff --git a/default-plugins/compact-bar/src/action_types.rs b/default-plugins/compact-bar/src/action_types.rs
index 7d1bd979..ddc91ead 100644
--- a/default-plugins/compact-bar/src/action_types.rs
+++ b/default-plugins/compact-bar/src/action_types.rs
@@ -34,6 +34,7 @@ pub enum ActionType {
NewTab,
Detach,
Quit,
+ NewStackedPane,
Other(String), // Fallback for unhandled actions
}
@@ -75,6 +76,7 @@ impl ActionType {
},
ActionType::SwitchToMode(input_mode) => format!("{:?}", input_mode),
ActionType::TogglePaneEmbedOrFloating => "Float or embed".to_string(),
+ ActionType::NewStackedPane => "New stacked pane".to_string(),
ActionType::ToggleFocusFullscreen => "Toggle fullscreen".to_string(),
ActionType::ToggleFloatingPanes => "Show/hide floating panes".to_string(),
ActionType::CloseFocus => "Close pane".to_string(),
@@ -101,6 +103,7 @@ impl ActionType {
Action::Search(_) => ActionType::Search,
Action::NewPane(Some(_), _, _) => ActionType::NewPaneWithDirection,
Action::NewPane(None, _, _) => ActionType::NewPaneWithoutDirection,
+ Action::NewStackedPane(_, _) => ActionType::NewStackedPane,
Action::BreakPaneLeft | Action::BreakPaneRight => ActionType::BreakPaneLeftOrRight,
Action::GoToPreviousTab | Action::GoToNextTab => ActionType::GoToAdjacentTab,
Action::ScrollUp | Action::ScrollDown => ActionType::Scroll,
diff --git a/default-plugins/compact-bar/src/keybind_utils.rs b/default-plugins/compact-bar/src/keybind_utils.rs
index 2a86dc88..68014169 100644
--- a/default-plugins/compact-bar/src/keybind_utils.rs
+++ b/default-plugins/compact-bar/src/keybind_utils.rs
@@ -50,7 +50,6 @@ impl KeybindProcessor {
let should_add_brackets_to_keys = mode != InputMode::Normal;
// Check if this is switching to normal mode
- // let is_switching_to_locked = matches!(first_action, Action::SwitchToMode(InputMode::Normal));
let is_switching_to_locked =
matches!(first_action, Action::SwitchToMode(InputMode::Locked));
@@ -334,6 +333,7 @@ impl KeybindProcessor {
|action: &Action| matches!(action, Action::ToggleFocusFullscreen),
|action: &Action| matches!(action, Action::ToggleFloatingPanes),
|action: &Action| matches!(action, Action::TogglePaneEmbedOrFloating),
+ |action: &Action| matches!(action, Action::NewStackedPane(None, None)),
|action: &Action| {
matches!(action, Action::NewPane(Some(Direction::Right), None, false))
},
diff --git a/default-plugins/compact-bar/src/main.rs b/default-plugins/compact-bar/src/main.rs
index 9dde0e31..ea99ef3a 100644
--- a/default-plugins/compact-bar/src/main.rs
+++ b/default-plugins/compact-bar/src/main.rs
@@ -58,6 +58,7 @@ struct State {
tooltip_is_active: bool,
persist: bool,
is_first_run: bool,
+ own_tab_index: Option<usize>,
}
struct TabRenderData {
@@ -103,6 +104,14 @@ impl ZellijPlugin for State {
} else if message.name == MSG_TOGGLE_TOOLTIP
&& message.is_private
&& self.toggle_tooltip_key.is_some()
+ && self.own_tab_index == Some(self.active_tab_idx.saturating_sub(1))
+ // only launch
+ // tooltip once
+ // even if there
+ // are a few
+ // instances of
+ // compact-bar
+ // running
{
self.toggle_persisted_tooltip(self.mode_info.mode);
}
@@ -224,7 +233,6 @@ impl State {
self.tabs = tabs;
should_render
} else {
- eprintln!("Could not find active tab.");
false
}
}
@@ -233,6 +241,7 @@ impl State {
if self.toggle_tooltip_key.is_some() {
let previous_tooltip_state = self.tooltip_is_active;
self.tooltip_is_active = self.detect_tooltip_presence(&pane_manifest);
+ self.own_tab_index = self.find_own_tab_index(&pane_manifest);
previous_tooltip_state != self.tooltip_is_active
} else {
false
@@ -321,6 +330,17 @@ impl State {
false
}
+ fn find_own_tab_index(&self, pane_manifest: &PaneManifest) -> Option<usize> {
+ for (tab_index, panes) in &pane_manifest.panes {
+ for pane in panes {
+ if pane.is_plugin && Some(pane.id) == self.own_plugin_id {
+ return Some(*tab_index);
+ }
+ }
+ }
+ None
+ }
+
fn handle_tab_click(&self, col: usize) {
if let Some(tab_idx) = get_tab_to_focus(&self.tab_line, self.active_tab_idx, col) {
switch_tab_to(tab_idx.try_into().unwrap());
@@ -539,7 +559,7 @@ fn bind_toggle_key_config(toggle_key: &str) -> String {
bind "{}" {{
MessagePlugin "compact-bar" {{
name "toggle_tooltip"
- toggle_tooltip_key "{}"
+ tooltip "{}"
}}
}}
}}