chore: Fix clippy::needless_borrow up to an editor

This commit is contained in:
Piotr Osiewicz
2024-01-21 15:03:24 +01:00
parent c3102feeeb
commit 6c82380232
29 changed files with 86 additions and 88 deletions
+2 -2
View File
@@ -1532,7 +1532,7 @@ impl LspCommand for GetCompletions {
.iter()
.map(language::proto::serialize_completion)
.collect(),
version: serialize_version(&buffer_version),
version: serialize_version(buffer_version),
}
}
@@ -1672,7 +1672,7 @@ impl LspCommand for GetCodeActions {
.iter()
.map(language::proto::serialize_code_action)
.collect(),
version: serialize_version(&buffer_version),
version: serialize_version(buffer_version),
}
}
+15 -16
View File
@@ -2947,7 +2947,7 @@ impl Project {
};
task.await;
this.update(&mut cx, |this, mut cx| {
this.update(&mut cx, |this, cx| {
let worktrees = this.worktrees.clone();
for worktree in worktrees {
let worktree = match worktree.upgrade() {
@@ -2962,7 +2962,7 @@ impl Project {
root_path,
adapter.clone(),
language.clone(),
&mut cx,
cx,
);
}
})
@@ -3544,8 +3544,8 @@ impl Project {
if errored {
log::warn!("test binary check failed");
let task = this
.update(&mut cx, move |this, mut cx| {
this.reinstall_language_server(language, adapter, server_id, &mut cx)
.update(&mut cx, move |this, cx| {
this.reinstall_language_server(language, adapter, server_id, cx)
})
.ok()
.flatten();
@@ -3768,8 +3768,7 @@ impl Project {
}
};
if let Some(relative_glob_pattern) = relative_glob_pattern {
let literal_prefix =
glob_literal_prefix(&relative_glob_pattern);
let literal_prefix = glob_literal_prefix(relative_glob_pattern);
tree.as_local_mut()
.unwrap()
.add_path_prefix_to_scan(Path::new(literal_prefix).into());
@@ -4231,9 +4230,9 @@ impl Project {
format_operation = Some(FormatOperation::Lsp(
Self::format_via_lsp(
&project,
&buffer,
buffer,
buffer_abs_path,
&language_server,
language_server,
tab_size,
&mut cx,
)
@@ -4252,8 +4251,8 @@ impl Project {
format_operation = Self::format_via_external_command(
buffer,
buffer_abs_path,
&command,
&arguments,
command,
arguments,
&mut cx,
)
.await
@@ -4276,9 +4275,9 @@ impl Project {
format_operation = Some(FormatOperation::Lsp(
Self::format_via_lsp(
&project,
&buffer,
buffer,
buffer_abs_path,
&language_server,
language_server,
tab_size,
&mut cx,
)
@@ -5847,7 +5846,7 @@ impl Project {
snapshot.file().map(|file| file.path().as_ref()),
) {
query
.search(&snapshot, None)
.search(snapshot, None)
.await
.iter()
.map(|range| {
@@ -6690,7 +6689,7 @@ impl Project {
snapshot.repository_and_work_directory_for_path(&path)?;
let repo = snapshot.get_local_repo(&repo)?;
let relative_path = path.strip_prefix(&work_directory).ok()?;
let base_text = repo.repo_ptr.lock().load_index_text(&relative_path);
let base_text = repo.repo_ptr.lock().load_index_text(relative_path);
Some((buffer, base_text))
})
.collect::<Vec<_>>()
@@ -6823,7 +6822,7 @@ impl Project {
for (_, _, path_summary) in
self.diagnostic_summaries(include_ignored, cx)
.filter(|(path, _, _)| {
let worktree = self.entry_for_path(&path, cx).map(|entry| entry.is_ignored);
let worktree = self.entry_for_path(path, cx).map(|entry| entry.is_ignored);
include_ignored || worktree == Some(false)
})
{
@@ -6849,7 +6848,7 @@ impl Project {
})
})
.filter(move |(path, _, _)| {
let worktree = self.entry_for_path(&path, cx).map(|entry| entry.is_ignored);
let worktree = self.entry_for_path(path, cx).map(|entry| entry.is_ignored);
include_ignored || worktree == Some(false)
})
}
+1 -1
View File
@@ -61,7 +61,7 @@ impl Project {
if let Some(python_settings) = &python_settings.as_option() {
let activate_script_path =
self.find_activate_script_path(&python_settings, working_directory);
self.find_activate_script_path(python_settings, working_directory);
self.activate_python_virtual_environment(
activate_script_path,
&terminal_handle,
+8 -8
View File
@@ -1437,7 +1437,7 @@ impl LocalWorktree {
if let Err(e) = self.client.send(proto::UpdateDiagnosticSummary {
project_id,
worktree_id: cx.entity_id().as_u64(),
summary: Some(summary.to_proto(server_id, &path)),
summary: Some(summary.to_proto(server_id, path)),
}) {
return Task::ready(Err(e));
}
@@ -2309,7 +2309,7 @@ impl LocalSnapshot {
impl BackgroundScannerState {
fn should_scan_directory(&self, entry: &Entry) -> bool {
(!entry.is_external && !entry.is_ignored)
|| entry.path.file_name() == Some(&*DOT_GIT)
|| entry.path.file_name() == Some(*DOT_GIT)
|| self.scanned_dirs.contains(&entry.id) // If we've ever scanned it, keep scanning
|| self
.paths_to_scan
@@ -3374,7 +3374,7 @@ impl BackgroundScanner {
let mut is_git_related = false;
if let Some(dot_git_dir) = abs_path
.ancestors()
.find(|ancestor| ancestor.file_name() == Some(&*DOT_GIT))
.find(|ancestor| ancestor.file_name() == Some(*DOT_GIT))
{
let dot_git_path = dot_git_dir
.strip_prefix(&root_canonical_path)
@@ -3772,7 +3772,7 @@ impl BackgroundScanner {
for entry in &mut new_entries {
state.reuse_entry_id(entry);
if entry.is_dir() {
if state.should_scan_directory(&entry) {
if state.should_scan_directory(entry) {
job_ix += 1;
} else {
log::debug!("defer scanning directory {:?}", entry.path);
@@ -3814,9 +3814,9 @@ impl BackgroundScanner {
abs_paths
.iter()
.map(|abs_path| async move {
let metadata = self.fs.metadata(&abs_path).await?;
let metadata = self.fs.metadata(abs_path).await?;
if let Some(metadata) = metadata {
let canonical_path = self.fs.canonicalize(&abs_path).await?;
let canonical_path = self.fs.canonicalize(abs_path).await?;
anyhow::Ok(Some((metadata, canonical_path)))
} else {
Ok(None)
@@ -3864,7 +3864,7 @@ impl BackgroundScanner {
fs_entry.is_external = !canonical_path.starts_with(&root_canonical_path);
if !is_dir && !fs_entry.is_ignored {
if let Some((work_dir, repo)) = state.snapshot.local_repo_for_path(&path) {
if let Some((work_dir, repo)) = state.snapshot.local_repo_for_path(path) {
if let Ok(repo_path) = path.strip_prefix(work_dir.0) {
let repo_path = RepoPath(repo_path.into());
let repo = repo.repo_ptr.lock();
@@ -3884,7 +3884,7 @@ impl BackgroundScanner {
state.insert_entry(fs_entry, self.fs.as_ref());
}
Ok(None) => {
self.remove_repo_path(&path, &mut state.snapshot);
self.remove_repo_path(path, &mut state.snapshot);
}
Err(err) => {
// TODO - create a special 'error' entry in the entries tree to mark this