chore: Fix several style lints (#17488)
It's not comprehensive enough to start linting on `style` group, but hey, it's a start. Release Notes: - N/A
This commit is contained in:
parent
93249fc82b
commit
e6c1c51b37
361 changed files with 3530 additions and 3587 deletions
|
@ -900,7 +900,7 @@ impl Project {
|
|||
dev_server_project_id: response
|
||||
.payload
|
||||
.dev_server_project_id
|
||||
.map(|dev_server_project_id| DevServerProjectId(dev_server_project_id)),
|
||||
.map(DevServerProjectId),
|
||||
search_history: Self::new_search_history(),
|
||||
search_included_history: Self::new_search_history(),
|
||||
search_excluded_history: Self::new_search_history(),
|
||||
|
@ -911,7 +911,7 @@ impl Project {
|
|||
};
|
||||
this.set_role(role, cx);
|
||||
for worktree in worktrees {
|
||||
let _ = this.add_worktree(&worktree, cx);
|
||||
this.add_worktree(&worktree, cx);
|
||||
}
|
||||
this
|
||||
})?;
|
||||
|
@ -1194,7 +1194,7 @@ impl Project {
|
|||
{
|
||||
prettier_plugins_by_worktree
|
||||
.entry(worktree)
|
||||
.or_insert_with(|| HashSet::default())
|
||||
.or_insert_with(HashSet::default)
|
||||
.extend(plugins.iter().cloned());
|
||||
}
|
||||
}
|
||||
|
@ -2090,7 +2090,7 @@ impl Project {
|
|||
};
|
||||
let buffer_file = buffer.read(cx).file().cloned();
|
||||
let settings =
|
||||
language_settings(Some(&new_language), buffer_file.as_ref(), cx).clone();
|
||||
language_settings(Some(new_language), buffer_file.as_ref(), cx).clone();
|
||||
let buffer_file = File::from_dyn(buffer_file.as_ref());
|
||||
let worktree = buffer_file.as_ref().map(|f| f.worktree_id(cx));
|
||||
if let Some(prettier_plugins) =
|
||||
|
@ -2233,7 +2233,7 @@ impl Project {
|
|||
}
|
||||
})
|
||||
.collect();
|
||||
if paths.len() > 0 {
|
||||
if !paths.is_empty() {
|
||||
let request = self.client.request(proto::UpdateDevServerProject {
|
||||
dev_server_project_id: dev_server_project_id.0,
|
||||
paths,
|
||||
|
@ -2739,7 +2739,7 @@ impl Project {
|
|||
.as_ref()
|
||||
.zip(buffer_abs_path.as_ref());
|
||||
|
||||
let prettier_settings = buffer.read_with(&mut cx, |buffer, cx| {
|
||||
let prettier_settings = buffer.read_with(&cx, |buffer, cx| {
|
||||
language_settings(buffer.language(), buffer.file(), cx)
|
||||
.prettier
|
||||
.clone()
|
||||
|
@ -2823,7 +2823,7 @@ impl Project {
|
|||
FormatOnSave::List(formatters) => {
|
||||
for formatter in formatters.as_ref() {
|
||||
let diff = Self::perform_format(
|
||||
&formatter,
|
||||
formatter,
|
||||
server_and_buffer,
|
||||
project.clone(),
|
||||
buffer,
|
||||
|
@ -2968,10 +2968,10 @@ impl Project {
|
|||
buffer: &Model<Buffer>,
|
||||
buffer_abs_path: &Option<PathBuf>,
|
||||
settings: &LanguageSettings,
|
||||
adapters_and_servers: &Vec<(Arc<CachedLspAdapter>, Arc<LanguageServer>)>,
|
||||
adapters_and_servers: &[(Arc<CachedLspAdapter>, Arc<LanguageServer>)],
|
||||
push_to_history: bool,
|
||||
transaction: &mut ProjectTransaction,
|
||||
mut cx: &mut AsyncAppContext,
|
||||
cx: &mut AsyncAppContext,
|
||||
) -> Result<Option<FormatOperation>, anyhow::Error> {
|
||||
let result = match formatter {
|
||||
Formatter::LanguageServer { name } => {
|
||||
|
@ -2982,7 +2982,7 @@ impl Project {
|
|||
.find_map(|(adapter, server)| {
|
||||
adapter.name.0.as_ref().eq(name.as_str()).then_some(server)
|
||||
})
|
||||
.unwrap_or_else(|| language_server)
|
||||
.unwrap_or(language_server)
|
||||
} else {
|
||||
language_server
|
||||
};
|
||||
|
@ -3004,36 +3004,28 @@ impl Project {
|
|||
None
|
||||
}
|
||||
}
|
||||
Formatter::Prettier => {
|
||||
prettier_support::format_with_prettier(&project, buffer, &mut cx)
|
||||
.await
|
||||
.transpose()
|
||||
.ok()
|
||||
.flatten()
|
||||
}
|
||||
Formatter::Prettier => prettier_support::format_with_prettier(&project, buffer, cx)
|
||||
.await
|
||||
.transpose()
|
||||
.ok()
|
||||
.flatten(),
|
||||
Formatter::External { command, arguments } => {
|
||||
let buffer_abs_path = buffer_abs_path.as_ref().map(|path| path.as_path());
|
||||
Self::format_via_external_command(
|
||||
buffer,
|
||||
buffer_abs_path,
|
||||
&command,
|
||||
&arguments,
|
||||
&mut cx,
|
||||
)
|
||||
.await
|
||||
.context(format!(
|
||||
"failed to format via external command {:?}",
|
||||
command
|
||||
))?
|
||||
.map(FormatOperation::External)
|
||||
Self::format_via_external_command(buffer, buffer_abs_path, command, arguments, cx)
|
||||
.await
|
||||
.context(format!(
|
||||
"failed to format via external command {:?}",
|
||||
command
|
||||
))?
|
||||
.map(FormatOperation::External)
|
||||
}
|
||||
Formatter::CodeActions(code_actions) => {
|
||||
let code_actions = deserialize_code_actions(&code_actions);
|
||||
let code_actions = deserialize_code_actions(code_actions);
|
||||
let lsp_store = project.update(cx, |p, _| p.lsp_store.downgrade())?;
|
||||
if !code_actions.is_empty() {
|
||||
LspStore::execute_code_actions_on_servers(
|
||||
&lsp_store,
|
||||
&adapters_and_servers,
|
||||
adapters_and_servers,
|
||||
code_actions,
|
||||
buffer,
|
||||
push_to_history,
|
||||
|
@ -3549,9 +3541,9 @@ impl Project {
|
|||
) -> Receiver<Model<Buffer>> {
|
||||
if self.is_local() {
|
||||
let fs = self.fs.clone();
|
||||
return self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store.find_search_candidates(query, limit, fs, cx)
|
||||
});
|
||||
})
|
||||
} else {
|
||||
self.search_for_candidate_buffers_remote(query, limit, cx)
|
||||
}
|
||||
|
@ -3582,7 +3574,7 @@ impl Project {
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
true
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let (tx, rx) = smol::channel::unbounded();
|
||||
|
@ -3777,10 +3769,10 @@ impl Project {
|
|||
.update(&mut cx, |worktree, _| {
|
||||
let root_entry_path = &worktree.root_entry()?.path;
|
||||
|
||||
let resolved = resolve_path(&root_entry_path, candidate);
|
||||
let resolved = resolve_path(root_entry_path, candidate);
|
||||
|
||||
let stripped =
|
||||
resolved.strip_prefix(&root_entry_path).unwrap_or(&resolved);
|
||||
resolved.strip_prefix(root_entry_path).unwrap_or(&resolved);
|
||||
|
||||
worktree.entry_for_path(stripped).map(|entry| {
|
||||
ResolvedPath::ProjectPath(ProjectPath {
|
||||
|
@ -3878,7 +3870,7 @@ impl Project {
|
|||
let fs = self.fs.clone();
|
||||
let task_abs_path = abs_path.clone();
|
||||
let tasks_file_rx =
|
||||
watch_config_file(&cx.background_executor(), fs, task_abs_path);
|
||||
watch_config_file(cx.background_executor(), fs, task_abs_path);
|
||||
task_inventory.add_source(
|
||||
TaskSourceKind::Worktree {
|
||||
id: remote_worktree_id,
|
||||
|
@ -3898,7 +3890,7 @@ impl Project {
|
|||
let fs = self.fs.clone();
|
||||
let task_abs_path = abs_path.clone();
|
||||
let tasks_file_rx =
|
||||
watch_config_file(&cx.background_executor(), fs, task_abs_path);
|
||||
watch_config_file(cx.background_executor(), fs, task_abs_path);
|
||||
task_inventory.add_source(
|
||||
TaskSourceKind::Worktree {
|
||||
id: remote_worktree_id,
|
||||
|
@ -5191,11 +5183,11 @@ impl<'a> Iterator for PathMatchCandidateSetIter<'a> {
|
|||
|
||||
impl EventEmitter<Event> for Project {}
|
||||
|
||||
impl<'a> Into<SettingsLocation<'a>> for &'a ProjectPath {
|
||||
fn into(self) -> SettingsLocation<'a> {
|
||||
impl<'a> From<&'a ProjectPath> for SettingsLocation<'a> {
|
||||
fn from(val: &'a ProjectPath) -> Self {
|
||||
SettingsLocation {
|
||||
worktree_id: self.worktree_id.to_usize(),
|
||||
path: self.path.as_ref(),
|
||||
worktree_id: val.worktree_id.to_usize(),
|
||||
path: val.path.as_ref(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5347,7 +5339,7 @@ fn deserialize_location(
|
|||
})
|
||||
}
|
||||
|
||||
pub fn sort_worktree_entries(entries: &mut Vec<Entry>) {
|
||||
pub fn sort_worktree_entries(entries: &mut [Entry]) {
|
||||
entries.sort_by(|entry_a, entry_b| {
|
||||
compare_paths(
|
||||
(&entry_a.path, entry_a.is_file()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue