aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-11-04 12:01:17 +0000
committerBlaž Hrastnik2022-11-04 12:06:28 +0000
commitc2c1280f02b83a468da67d88350c199915427535 (patch)
treecd4306c1b7353bb960608e18c5633aa22c5d0204 /helix-term/src
parent921d3510132b0bd89d4ac0a542371c3ae90e2e02 (diff)
Resolve a bunch of upcoming clippy lints
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/application.rs4
-rw-r--r--helix-term/src/commands.rs15
-rw-r--r--helix-term/src/commands/lsp.rs6
-rw-r--r--helix-term/src/ui/menu.rs2
-rw-r--r--helix-term/src/ui/prompt.rs4
5 files changed, 14 insertions, 17 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 173c5d49..e356c1f9 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -168,7 +168,7 @@ impl Application {
} else if !args.files.is_empty() {
let first = &args.files[0].0; // we know it's not empty
if first.is_dir() {
- std::env::set_current_dir(&first).context("set current dir")?;
+ std::env::set_current_dir(first).context("set current dir")?;
editor.new_file(Action::VerticalSplit);
let picker = ui::file_picker(".".into(), &config.load().editor);
compositor.push(Box::new(overlayed(picker)));
@@ -228,7 +228,7 @@ impl Application {
#[cfg(windows)]
let signals = futures_util::stream::empty();
#[cfg(not(windows))]
- let signals = Signals::new(&[signal::SIGTSTP, signal::SIGCONT, signal::SIGUSR1])
+ let signals = Signals::new([signal::SIGTSTP, signal::SIGCONT, signal::SIGUSR1])
.context("build signal handler")?;
let app = Self {
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index ee9bad98..aae9979d 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -3933,15 +3933,12 @@ pub fn completion(cx: &mut Context) {
};
if !prefix.is_empty() {
- items = items
- .into_iter()
- .filter(|item| {
- item.filter_text
- .as_ref()
- .unwrap_or(&item.label)
- .starts_with(&prefix)
- })
- .collect();
+ items.retain(|item| {
+ item.filter_text
+ .as_ref()
+ .unwrap_or(&item.label)
+ .starts_with(&prefix)
+ });
}
if items.is_empty() {
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index d7617c50..5498fc83 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -57,7 +57,7 @@ impl ui::menu::Item for lsp::Location {
// allocation, for `to_file_path`, else there will be two (2), with `to_string_lossy`.
let mut write_path_to_res = || -> Option<()> {
let path = self.uri.to_file_path().ok()?;
- res.push_str(&path.strip_prefix(&cwdir).unwrap_or(&path).to_string_lossy());
+ res.push_str(&path.strip_prefix(cwdir).unwrap_or(&path).to_string_lossy());
Some(())
};
write_path_to_res();
@@ -634,7 +634,7 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
// Create directory if it does not exist
if let Some(dir) = path.parent() {
if !dir.is_dir() {
- fs::create_dir_all(&dir)?;
+ fs::create_dir_all(dir)?;
}
}
@@ -910,7 +910,7 @@ pub fn goto_reference(cx: &mut Context) {
);
}
-#[derive(PartialEq)]
+#[derive(PartialEq, Eq)]
pub enum SignatureHelpInvoked {
Manual,
Automatic,
diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs
index 99c2473d..1baaf40a 100644
--- a/helix-term/src/ui/menu.rs
+++ b/helix-term/src/ui/menu.rs
@@ -40,7 +40,7 @@ impl Item for PathBuf {
type Data = PathBuf;
fn label(&self, root_path: &Self::Data) -> Spans {
- self.strip_prefix(&root_path)
+ self.strip_prefix(root_path)
.unwrap_or(self)
.to_string_lossy()
.into()
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index d0991d3c..ca2872a7 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -32,7 +32,7 @@ pub struct Prompt {
next_char_handler: Option<PromptCharHandler>,
}
-#[derive(Clone, Copy, PartialEq)]
+#[derive(Clone, Copy, PartialEq, Eq)]
pub enum PromptEvent {
/// The prompt input has been updated.
Update,
@@ -408,7 +408,7 @@ impl Prompt {
surface.set_stringn(
area.x + col * (1 + col_width),
area.y + row,
- &completion,
+ completion,
col_width.saturating_sub(1) as usize,
color,
);