diff options
author | Paulo Coelho <9609090+prscoelho@users.noreply.github.com> | 2022-09-09 08:48:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-09 09:48:02 +0200 |
commit | b9e57cfdadf0601cc919e2dc86c1d67b2383d8a0 (patch) | |
tree | b65e7b96e17fc3707d600c27b11b1e6f8105838d /default-plugins/tab-bar/src/main.rs | |
parent | ebbd46ea3bcc10f003ca4b83b28c550b953dc2a1 (diff) |
fix(tab-bar): mouse-click in simplified-ui (#1658)
* fix(tab-bar): fix tab bar click when tabs are collapsed
* fix(tab-bar): calculate tab length correctly for any separator
* fix(tab-bar): fix clippy
Diffstat (limited to 'default-plugins/tab-bar/src/main.rs')
-rw-r--r-- | default-plugins/tab-bar/src/main.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index b11ab87c2..562e27793 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -13,6 +13,7 @@ use crate::tab::tab_style; pub struct LinePart { part: String, len: usize, + tab_index: Option<usize>, } #[derive(Default)] @@ -88,12 +89,10 @@ impl ZellijPlugin for State { } let tab = tab_style( tabname, - t.active, + t, is_alternate_tab, - t.is_sync_panes_active, self.mode_info.style.colors, self.mode_info.capabilities, - t.other_focused_clients.as_slice(), ); is_alternate_tab = !is_alternate_tab; all_tabs.push(tab); @@ -108,17 +107,17 @@ impl ZellijPlugin for State { ); let mut s = String::new(); let mut len_cnt = 0; - for (idx, bar_part) in tab_line.iter().enumerate() { + for bar_part in tab_line { s = format!("{}{}", s, &bar_part.part); if self.should_render - && self.mouse_click_pos > len_cnt - && self.mouse_click_pos <= len_cnt + bar_part.len - && idx > 2 + && self.mouse_click_pos >= len_cnt + && self.mouse_click_pos < len_cnt + bar_part.len + && bar_part.tab_index.is_some() { - // First three elements of tab_line are "Zellij", session name and empty thing, hence the idx > 2 condition. - // Tabs are indexed starting from 1, therefore we need subtract 2 below. - switch_tab_to(TryInto::<u32>::try_into(idx).unwrap() - 2); + // Tabs are indexed starting from 1, therefore we need add 1 to tab_index. + let tab_index: u32 = bar_part.tab_index.unwrap().try_into().unwrap(); + switch_tab_to(tab_index + 1); } len_cnt += bar_part.len; } |