Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy lint from most recent Rust #646

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/menu/list_menu.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand Down Expand Up @@ -625,11 +624,17 @@
// 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::<String>();
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
},
);

Check warning on line 637 in src/menu/list_menu.rs

View check run for this annotation

Codecov / codecov/patch

src/menu/list_menu.rs#L627-L637

Added lines #L627 - L637 were not covered by tests

lines + "..."
} else {
Expand Down