From 0d68b46fbf33c08abdd815f098a8b33d6ecb6353 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Sun, 15 Oct 2023 21:12:13 +0200 Subject: [PATCH] Fix clippy lint from most recent Rust https://rust-lang.github.io/rust-clippy/master/index.html#/format_collect --- src/menu/list_menu.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/menu/list_menu.rs b/src/menu/list_menu.rs index 9e2e4807..5b10e68d 100644 --- a/src/menu/list_menu.rs +++ b/src/menu/list_menu.rs @@ -1,16 +1,15 @@ -use crate::{core_editor::Editor, UndoBehavior}; - use { super::{ menu_functions::{parse_selection_char, string_difference}, Menu, MenuEvent, MenuTextStyle, }, crate::{ + core_editor::Editor, painting::{estimate_single_line_wraps, Painter}, - Completer, Suggestion, + Completer, Suggestion, UndoBehavior, }, nu_ansi_term::{ansi::RESET, Style}, - std::iter::Sum, + std::{fmt::Write, iter::Sum}, unicode_width::UnicodeWidthStr, }; @@ -625,11 +624,17 @@ impl Menu for ListMenu { // Final string with colors let line = &suggestion.value; let line = if line.lines().count() > self.max_lines as usize { - let lines = line - .lines() - .take(self.max_lines as usize) - .map(|string| format!("{}\r\n{}", string, self.multiline_marker)) - .collect::(); + let lines = line.lines().take(self.max_lines as usize).fold( + String::new(), + |mut out_string, string| { + let _ = write!( + out_string, + "{}\r\n{}", + string, self.multiline_marker + ); + out_string + }, + ); lines + "..." } else {