fix(compact-bar): tooltip duplication (#4310)
* fix(tooltip): update config name and only launch once * add new stacked pane to tooltip
This commit is contained in:
parent
16d8e6d0ab
commit
ba680fc2eb
3 changed files with 26 additions and 3 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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 "{}"
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue