More practical clippy settings, simplify some checks
This commit is contained in:
parent
fa70f3fd61
commit
ec01b65bce
@ -65,7 +65,6 @@ impl Editor {
|
|||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
let mut initial_status = String::from("HELP: Ctrl-S = save | Ctrl-Q = quit");
|
let mut initial_status = String::from("HELP: Ctrl-S = save | Ctrl-Q = quit");
|
||||||
let document = if let Some(file_name) = args.get(1) {
|
let document = if let Some(file_name) = args.get(1) {
|
||||||
let file_name = &args[1];
|
|
||||||
let doc = Document::open(&file_name);
|
let doc = Document::open(&file_name);
|
||||||
if let Ok(doc) = doc {
|
if let Ok(doc) = doc {
|
||||||
doc
|
doc
|
||||||
@ -285,11 +284,8 @@ impl Editor {
|
|||||||
let terminal_height = self.terminal.size().height as usize;
|
let terminal_height = self.terminal.size().height as usize;
|
||||||
let Position { mut y, mut x } = self.cursor_position;
|
let Position { mut y, mut x } = self.cursor_position;
|
||||||
let height = self.document.len();
|
let height = self.document.len();
|
||||||
let mut width = if let Some(row) = self.document.row(y) {
|
|
||||||
row.len()
|
let mut width = self.document.row(y).map_or(0, Row::len);
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
match key {
|
match key {
|
||||||
Key::Up => y = y.saturating_sub(1),
|
Key::Up => y = y.saturating_sub(1),
|
||||||
@ -303,11 +299,7 @@ impl Editor {
|
|||||||
x -= 1;
|
x -= 1;
|
||||||
} else if y > 0 {
|
} else if y > 0 {
|
||||||
y -= 1;
|
y -= 1;
|
||||||
if let Some(row) = self.document.row(y) {
|
x = self.document.row(y).map_or(0, Row::len);
|
||||||
x = row.len()
|
|
||||||
} else {
|
|
||||||
x = 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Key::Right => {
|
Key::Right => {
|
||||||
@ -337,11 +329,7 @@ impl Editor {
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
width = if let Some(row) = self.document.row(y) {
|
width = self.document.row(y).map_or(0, Row::len);
|
||||||
row.len()
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
if x > width {
|
if x > width {
|
||||||
x = width;
|
x = width;
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -1,11 +1,8 @@
|
|||||||
#![warn(clippy::all, clippy::pedantic, clippy::restriction)]
|
#![warn(clippy::all, clippy::pedantic)]
|
||||||
#![allow(
|
#![allow(
|
||||||
clippy::missing_docs_in_private_items,
|
clippy::missing_errors_doc,
|
||||||
clippy::implicit_return,
|
clippy::must_use_candidate,
|
||||||
clippy::shadow_reuse,
|
clippy::panic,
|
||||||
clippy::print_stdout,
|
|
||||||
clippy::wildcard_enum_match_arm,
|
|
||||||
clippy::else_if_without_else
|
|
||||||
)]
|
)]
|
||||||
mod document;
|
mod document;
|
||||||
mod editor;
|
mod editor;
|
||||||
|
Loading…
Reference in New Issue
Block a user