diff options
39 files changed, 358 insertions, 360 deletions
diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs index b3dea2783..5bc510868 100644 --- a/default-plugins/status-bar/src/first_line.rs +++ b/default-plugins/status-bar/src/first_line.rs @@ -93,7 +93,7 @@ fn selected_mode_shortcut( ) -> LinePart { let prefix_separator = palette.selected_prefix_separator.paint(separator); let char_left_separator = palette.selected_char_left_separator.paint(" <".to_string()); - let char_shortcut = palette.selected_char_shortcut.paint(format!("{}", letter)); + let char_shortcut = palette.selected_char_shortcut.paint(letter.to_string()); let char_right_separator = palette.selected_char_right_separator.paint(">".to_string()); let styled_text = palette.selected_styled_text.paint(format!("{} ", text)); let suffix_separator = palette.selected_suffix_separator.paint(separator); diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index 1ecd87ab1..ce80dab14 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -176,7 +176,7 @@ impl ZellijPlugin for State { let first_line = format!("{}{}", superkey, ctrl_keys); let mut second_line = LinePart::default(); - for t in self.tabs.iter_mut() { + for t in &mut self.tabs { if t.active { match self.mode_info.mode { InputMode::Normal => { diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs index 1b90443c0..9cc978a61 100644 --- a/default-plugins/status-bar/src/second_line.rs +++ b/default-plugins/status-bar/src/second_line.rs @@ -31,16 +31,14 @@ fn full_length_shortcut( let description = Style::new().fg(white_color).bold().paint(description); let len = shortcut_len + description_len + separator.chars().count(); LinePart { - part: format!( - "{}", - ANSIStrings(&[ - separator, - shortcut_left_separator, - shortcut, - shortcut_right_separator, - description - ]) - ), + part: ANSIStrings(&[ + separator, + shortcut_left_separator, + shortcut, + shortcut_right_separator, + description, + ]) + .to_string(), len, } } @@ -73,16 +71,14 @@ fn first_word_shortcut( .paint(description_first_word); let len = shortcut_len + description_first_word_length + separator.chars().count(); LinePart { - part: format!( - "{}", - ANSIStrings(&[ - separator, - shortcut_left_separator, - shortcut, - shortcut_right_separator, - description_first_word, - ]) - ), + part: ANSIStrings(&[ + separator, + shortcut_left_separator, + shortcut, + shortcut_right_separator, + description_first_word, + ]) + .to_string(), len, } } @@ -284,7 +280,7 @@ fn locked_interface_indication(palette: Palette) -> LinePart { }; let locked_styled_text = Style::new().fg(white_color).bold().paint(locked_text); LinePart { - part: format!("{}", locked_styled_text), + part: locked_styled_text.to_string(), len: locked_text_len, } } @@ -310,16 +306,14 @@ fn select_pane_shortcut(is_first_shortcut: bool, palette: Palette) -> LinePart { let description = Style::new().fg(white_color).bold().paint(description); let len = shortcut_len + description_len + separator.chars().count(); LinePart { - part: format!( - "{}", - ANSIStrings(&[ - separator, - shortcut_left_separator, - shortcut, - shortcut_right_separator, - description - ]) - ), + part: ANSIStrings(&[ + separator, + shortcut_left_separator, + shortcut, + shortcut_right_separator, + description, + ]) + .to_string(), len, } } @@ -422,7 +416,7 @@ pub fn text_copied_hint(palette: &Palette) -> LinePart { PaletteColor::EightBit(color) => Fixed(color), }; LinePart { - part: format!("{}", Style::new().fg(green_color).bold().paint(hint)), + part: Style::new().fg(green_color).bold().paint(hint).to_string(), len: hint.len(), } } 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, diff --git a/src/commands.rs b/src/commands.rs index d1bcb4561..ec6268f21 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -40,7 +40,7 @@ pub(crate) fn kill_all_sessions(yes: bool) { process::exit(1); } } - for session in sessions.iter() { + for session in &sessions { kill_session_impl(session); } process::exit(0); @@ -131,7 +131,7 @@ fn attach_with_session_name( config_options: Options, create: bool, ) -> ClientInfo { - match session_name.as_ref() { + match &session_name { Some(session) if create => { if !session_exists(session).unwrap() { ClientInfo::New(session_name.unwrap()) diff --git a/src/tests/e2e/cases.rs b/src/tests/e2e/cases.rs index 0198adfe0..0585c373b 100644 --- a/src/tests/e2e/cases.rs +++ b/src/tests/e2e/cases.rs @@ -5,6 +5,7 @@ use zellij_utils::{pane_size::Size, position::Position}; use rand::Rng; +use std::fmt::Write; use std::path::Path; use super::remote_runner::{RemoteRunner, RemoteTerminal, Step}; @@ -231,26 +232,26 @@ pub fn scrolling_inside_a_pane() { if remote_terminal.cursor_position_is(63, 2) && remote_terminal.tip_appears() { // cursor is in the newly opened second pane let mut content_to_send = String::new(); - content_to_send.push_str(&format!("{:0<56}", "line1 ")); - content_to_send.push_str(&format!("{:0<58}", "line2 ")); - content_to_send.push_str(&format!("{:0<58}", "line3 ")); - content_to_send.push_str(&format!("{:0<58}", "line4 ")); - content_to_send.push_str(&format!("{:0<58}", "line5 ")); - content_to_send.push_str(&format!("{:0<58}", "line6 ")); - content_to_send.push_str(&format!("{:0<58}", "line7 ")); - content_to_send.push_str(&format!("{:0<58}", "line8 ")); - content_to_send.push_str(&format!("{:0<58}", "line9 ")); - content_to_send.push_str(&format!("{:0<58}", "line10 ")); - content_to_send.push_str(&format!("{:0<58}", "line11 ")); - content_to_send.push_str(&format!("{:0<58}", "line12 ")); - content_to_send.push_str(&format!("{:0<58}", "line13 ")); - content_to_send.push_str(&format!("{:0<58}", "line14 ")); - content_to_send.push_str(&format!("{:0<58}", "line15 ")); - content_to_send.push_str(&format!("{:0<58}", "line16 ")); - content_to_send.push_str(&format!("{:0<58}", "line17 ")); - content_to_send.push_str(&format!("{:0<58}", "line18 ")); - content_to_send.push_str(&format!("{:0<58}", "line19 ")); - content_to_send.push_str(&format!("{:0<57}", "line20 ")); + write!(&mut content_to_send, "{:0<56}", "line1 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line2 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line3 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line4 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line5 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line6 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line7 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line8 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line9 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line10 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line11 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line12 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line13 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line14 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line15 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line16 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line17 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line18 ").unwrap(); + write!(&mut content_to_send, "{:0<58}", "line19 ").unwrap(); + write!(&mut content_to_send, "{:0<57}", "line20 ").unwrap(); remote_terminal.send_key(content_to_send.as_bytes()); diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs index 46e2b88f1..e27e9fc21 100644 --- a/src/tests/e2e/remote_runner.rs +++ b/src/tests/e2e/remote_runner.rs @@ -45,14 +45,12 @@ fn setup_remote_environment(channel: &mut ssh2::Channel, win_size: Size) { .request_pty("xterm", None, Some((columns, rows, 0, 0))) .unwrap(); channel.shell().unwrap(); - channel.write_all("export PS1=\"$ \"\n".as_bytes()).unwrap(); + channel.write_all(b"export PS1=\"$ \"\n").unwrap(); channel.flush().unwrap(); } fn stop_zellij(channel: &mut ssh2::Channel) { - channel - .write_all("killall -KILL zellij\n".as_bytes()) - .unwrap(); + channel.write_all(b"killall -KILL zellij\n").unwrap(); } fn start_zellij(channel: &mut ssh2::Channel) { diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index f3daf69c8..38ab30210 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -299,9 +299,9 @@ pub fn start_client( os_input.send_to_server(ClientToServerMsg::ClientExited); if let ExitReason::Error(_) = reason { - handle_error(format!("{}", reason)); + handle_error(reason.to_string()); } - exit_msg = format!("{}", reason); + exit_msg = reason.to_string(); break; } ClientInstruction::Error(backtrace) => { diff --git a/zellij-client/src/stdin_handler.rs b/zellij-client/src/stdin_handler.rs index 177f08e18..7d93ac4dd 100644 --- a/zellij-client/src/stdin_handler.rs +++ b/zellij-client/src/stdin_handler.rs @@ -66,14 +66,14 @@ pub(crate) fn stdin_loop( && stdin_buffer .iter() .take(bracketed_paste_start.len()) - .eq(bracketed_paste_start.iter())) + .eq(&bracketed_paste_start)) { match bracketed_paste_end_position(&stdin_buffer) { Some(paste_end_position) => { let starts_with_bracketed_paste_start = stdin_buffer .iter() .take(bracketed_paste_start.len()) - .eq(bracketed_paste_start.iter()); + .eq(&bracketed_paste_start); let ends_with_bracketed_paste_end = true; @@ -97,7 +97,7 @@ pub(crate) fn stdin_loop( let starts_with_bracketed_paste_start = stdin_buffer .iter() .take(bracketed_paste_start.len()) - .eq(bracketed_paste_start.iter()); + .eq(&bracketed_paste_start); if starts_with_bracketed_paste_start { drop(stdin_buffer.drain(..6)); // bracketed paste start } diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs index cb8f050dc..391a03f6f 100644 --- a/zellij-server/src/lib.rs +++ b/zellij-server/src/lib.rs @@ -451,9 +451,8 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) { // Here the output is of the type Option<String> sent by screen thread. // If `Some(_)`- unwrap it and forward it to the clients to render. // If `None`- Send an exit instruction. This is the case when a user closes the last Tab/Pane. - if let Some(op) = output.as_mut() { - for (client_id, client_render_instruction) in - op.client_render_instructions.iter_mut() + if let Some(op) = &mut output { |