diff options
author | Marcin Puc <5671049+tranzystorek-io@users.noreply.github.com> | 2021-12-07 11:24:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-07 10:24:42 +0000 |
commit | 56e85f87d6c365816cca71c496aa7e49709e0b11 (patch) | |
tree | 1dbc6db878e8da9544df9445d77d1cd665b9126b /default-plugins/tab-bar | |
parent | d34e6240101d246f02921cbc909dcd04f648203e (diff) |
fix(style): various internal refactorings
Diffstat (limited to 'default-plugins/tab-bar')
-rw-r--r-- | default-plugins/tab-bar/src/line.rs | 16 | ||||
-rw-r--r-- | default-plugins/tab-bar/src/main.rs | 4 | ||||
-rw-r--r-- | default-plugins/tab-bar/src/tab.rs | 12 |
3 files changed, 12 insertions, 20 deletions
diff --git a/default-plugins/tab-bar/src/line.rs b/default-plugins/tab-bar/src/line.rs index 2e180845b..b8c58854d 100644 --- a/default-plugins/tab-bar/src/line.rs +++ b/default-plugins/tab-bar/src/line.rs @@ -107,10 +107,8 @@ fn left_more_message(tab_count_to_the_left: usize, palette: Palette, separator: .bold() .paint(more_text); let right_separator = style!(palette.orange, palette.gray).paint(separator); - let more_styled_text = format!( - "{}", - ANSIStrings(&[left_separator, more_styled_text, right_separator,]) - ); + let more_styled_text = + ANSIStrings(&[left_separator, more_styled_text, right_separator]).to_string(); LinePart { part: more_styled_text, len: more_text_len, @@ -137,10 +135,8 @@ fn right_more_message( .bold() .paint(more_text); let right_separator = style!(palette.orange, palette.gray).paint(separator); - let more_styled_text = format!( - "{}", - ANSIStrings(&[left_separator, more_styled_text, right_separator,]) - ); + let more_styled_text = + ANSIStrings(&[left_separator, more_styled_text, right_separator]).to_string(); LinePart { part: more_styled_text, len: more_text_len, @@ -155,7 +151,7 @@ fn tab_line_prefix(session_name: Option<&str>, palette: Palette, cols: usize) -> .bold() .paint(prefix_text); let mut parts = vec![LinePart { - part: format!("{}", prefix_styled_text), + part: prefix_styled_text.to_string(), len: prefix_text_len, }]; if let Some(name) = session_name { @@ -164,7 +160,7 @@ fn tab_line_prefix(session_name: Option<&str>, palette: Palette, cols: usize) -> let name_part_styled_text = style!(palette.white, palette.gray).bold().paint(name_part); if cols.saturating_sub(prefix_text_len) >= name_part_len { parts.push(LinePart { - part: format!("{}", name_part_styled_text), + part: name_part_styled_text.to_string(), len: name_part_len, }) } diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index 5902050ae..31b2f2d37 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -43,7 +43,7 @@ impl ZellijPlugin for State { Event::ModeUpdate(mode_info) => self.mode_info = mode_info, Event::TabUpdate(tabs) => { // tabs are indexed starting from 1 so we need to add 1 - self.active_tab_idx = (&tabs).iter().position(|t| t.active).unwrap() + 1; + self.active_tab_idx = tabs.iter().position(|t| t.active).unwrap() + 1; self.tabs = tabs; } Event::Mouse(me) => match me { @@ -69,7 +69,7 @@ impl ZellijPlugin for State { } let mut all_tabs: Vec<LinePart> = vec![]; let mut active_tab_index = 0; - for t in self.tabs.iter_mut() { + for t in &mut self.tabs { let mut tabname = t.name.clone(); if t.active && self.mode_info.mode == InputMode::RenameTab { if tabname.is_empty() { diff --git a/default-plugins/tab-bar/src/tab.rs b/default-plugins/tab-bar/src/tab.rs index fc34b6c36..db960fd52 100644 --- a/default-plugins/tab-bar/src/tab.rs +++ b/default-plugins/tab-bar/src/tab.rs @@ -11,10 +11,8 @@ pub fn active_tab(text: String, palette: Palette, separator: &str) -> LinePart { .bold() .paint(format!(" {} ", text)); let right_separator = style!(palette.green, palette.gray).paint(separator); - let tab_styled_text = format!( - "{}", - ANSIStrings(&[left_separator, tab_styled_text, right_separator,]) - ); + let tab_styled_text = + ANSIStrings(&[left_separator, tab_styled_text, right_separator]).to_string(); LinePart { part: tab_styled_text, len: tab_text_len, @@ -28,10 +26,8 @@ pub fn non_active_tab(text: String, palette: Palette, separator: &str) -> LinePa .bold() .paint(format!(" {} ", text)); let right_separator = style!(palette.fg, palette.gray).paint(separator); - let tab_styled_text = format!( - "{}", - ANSIStrings(&[left_separator, tab_styled_text, right_separator,]) - ); + let tab_styled_text = + ANSIStrings(&[left_separator, tab_styled_text, right_separator]).to_string(); LinePart { part: tab_styled_text, len: tab_text_len, |