summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2023-07-02 11:29:15 -0400
committerJeff Zhao <jeff.no.zhao@gmail.com>2023-07-02 11:29:15 -0400
commitabb59d4684dd8eb13176a579dfa59d355fbc14e1 (patch)
tree37f674b82d2b6df64259fa467bfa606733225804
parent00d011fd22ac56bd1add71cc8110ac2956333d1a (diff)
cargo clippy
-rw-r--r--src/ui/views/tui_textfield.rs20
-rw-r--r--src/util/unix.rs5
2 files changed, 11 insertions, 14 deletions
diff --git a/src/ui/views/tui_textfield.rs b/src/ui/views/tui_textfield.rs
index ba783fd..2bdbd96 100644
--- a/src/ui/views/tui_textfield.rs
+++ b/src/ui/views/tui_textfield.rs
@@ -1,9 +1,9 @@
use std::str::FromStr;
-use rustyline::completion::{Candidate, Completer, FilenameCompleter, Pair};
-use rustyline::history::{History, SearchDirection};
+use rustyline::completion::{Candidate, FilenameCompleter, Pair};
+use rustyline::history::SearchDirection;
use rustyline::line_buffer::{self, ChangeListener, DeleteListener, Direction, LineBuffer};
-use rustyline::{At, Changeset, Word};
+use rustyline::{At, Word};
use termion::event::{Event, Key};
use tui::layout::Rect;
@@ -330,8 +330,7 @@ fn autocomplete_forward(
if ct.index + 1 >= ct.candidates.len() {
return false;
}
- ct.index = ct.index + 1;
-
+ ct.index += 1;
let candidate = &ct.candidates[ct.index];
let pos = ct.pos;
@@ -339,7 +338,7 @@ fn autocomplete_forward(
line_buffer.set_pos(pos);
line_buffer.kill_buffer(listener);
- line_buffer.insert_str(pos, &first, listener);
+ line_buffer.insert_str(pos, first, listener);
line_buffer.move_end();
} else if let Some((pos, mut candidates)) = get_candidates(completer, line_buffer) {
if !candidates.is_empty() {
@@ -349,17 +348,18 @@ fn autocomplete_forward(
.unwrap_or(std::cmp::Ordering::Less)
});
- let first = candidates[0].display().to_string();
let mut ct =
CompletionTracker::new(pos, candidates, String::from(line_buffer.as_str()));
ct.index = 0;
-
- *completion_tracker = Some(ct);
+ let candidate = &ct.candidates[0];
+ let first = candidate.display();
line_buffer.set_pos(pos);
line_buffer.kill_buffer(listener);
- line_buffer.insert_str(pos, &first, listener);
+ line_buffer.insert_str(pos, first, listener);
line_buffer.move_end();
+
+ *completion_tracker = Some(ct);
}
}
diff --git a/src/util/unix.rs b/src/util/unix.rs
index 5e05473..ac66e2b 100644
--- a/src/util/unix.rs
+++ b/src/util/unix.rs
@@ -60,10 +60,7 @@ pub fn expand_shell_string(s: &str) -> path::PathBuf {
let dir = dirs_next::home_dir();
let os_str = dir.map(|s| s.as_os_str().to_owned());
let context_func = || {
- let cow_str = match os_str.as_ref() {
- Some(s) => Some(s.to_string_lossy()),
- None => None,
- };
+ let cow_str = os_str.as_ref().map(|s| s.to_string_lossy());
cow_str
};
let tilde_cow = shellexpand::tilde_with_context(s, context_func);