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:
Piotr Osiewicz 2024-09-06 11:58:39 +02:00 committed by GitHub
parent 93249fc82b
commit e6c1c51b37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
361 changed files with 3530 additions and 3587 deletions

View file

@ -91,11 +91,10 @@ impl BufferStore {
remote_id: Option<u64>,
cx: &mut ModelContext<Self>,
) -> Self {
cx.subscribe(&worktree_store, |this, _, event, cx| match event {
WorktreeStoreEvent::WorktreeAdded(worktree) => {
cx.subscribe(&worktree_store, |this, _, event, cx| {
if let WorktreeStoreEvent::WorktreeAdded(worktree) = event {
this.subscribe_to_worktree(worktree, cx);
}
_ => {}
})
.detach();
@ -711,7 +710,7 @@ impl BufferStore {
pub fn get_by_path(&self, path: &ProjectPath, cx: &AppContext) -> Option<Model<Buffer>> {
self.buffers().find_map(|buffer| {
let file = File::from_dyn(buffer.read(cx).file())?;
if file.worktree_id(cx) == path.worktree_id && &file.path == &path.path {
if file.worktree_id(cx) == path.worktree_id && file.path == path.path {
Some(buffer)
} else {
None
@ -885,11 +884,8 @@ impl BufferStore {
event: &BufferEvent,
cx: &mut ModelContext<Self>,
) {
match event {
BufferEvent::FileHandleChanged => {
self.buffer_changed_file(buffer, cx);
}
_ => {}
if event == &BufferEvent::FileHandleChanged {
self.buffer_changed_file(buffer, cx);
}
}

View file

@ -204,7 +204,7 @@ impl Manager {
// we leave the room and return an error.
if let Some(this) = this.upgrade() {
log::info!("reconnection failed, disconnecting projects");
let _ = this.update(&mut cx, |this, cx| this.connection_lost(cx))?;
this.update(&mut cx, |this, cx| this.connection_lost(cx))?;
}
Ok(())

View file

@ -8,6 +8,12 @@ pub struct DebouncedDelay<E: 'static> {
_phantom_data: PhantomData<E>,
}
impl<E: 'static> Default for DebouncedDelay<E> {
fn default() -> Self {
Self::new()
}
}
impl<E: 'static> DebouncedDelay<E> {
pub fn new() -> Self {
Self {

View file

@ -29,11 +29,10 @@ impl ProjectEnvironment {
cx: &mut AppContext,
) -> Model<Self> {
cx.new_model(|cx| {
cx.subscribe(worktree_store, |this: &mut Self, _, event, _| match event {
WorktreeStoreEvent::WorktreeRemoved(_, id) => {
cx.subscribe(worktree_store, |this: &mut Self, _, event, _| {
if let WorktreeStoreEvent::WorktreeRemoved(_, id) = event {
this.remove_worktree_environment(*id);
}
_ => {}
})
.detach();
@ -160,9 +159,9 @@ enum EnvironmentOrigin {
WorktreeShell,
}
impl Into<String> for EnvironmentOrigin {
fn into(self) -> String {
match self {
impl From<EnvironmentOrigin> for String {
fn from(val: EnvironmentOrigin) -> Self {
match val {
EnvironmentOrigin::Cli => "cli".into(),
EnvironmentOrigin::WorktreeShell => "worktree-shell".into(),
}

View file

@ -728,11 +728,10 @@ impl LspCommand for GetTypeDefinition {
type ProtoRequest = proto::GetTypeDefinition;
fn check_capabilities(&self, capabilities: AdapterServerCapabilities) -> bool {
match &capabilities.server_capabilities.type_definition_provider {
None => false,
Some(lsp::TypeDefinitionProviderCapability::Simple(false)) => false,
_ => true,
}
!matches!(
&capabilities.server_capabilities.type_definition_provider,
None | Some(lsp::TypeDefinitionProviderCapability::Simple(false))
)
}
fn to_lsp(
@ -1037,7 +1036,7 @@ impl LspCommand for GetReferences {
type ProtoRequest = proto::GetReferences;
fn status(&self) -> Option<String> {
return Some("Finding references...".to_owned());
Some("Finding references...".to_owned())
}
fn check_capabilities(&self, capabilities: AdapterServerCapabilities) -> bool {
@ -1469,7 +1468,7 @@ impl LspCommand for GetSignatureHelp {
let language = buffer.update(&mut cx, |buffer, _| buffer.language().cloned())?;
Ok(response
.signature_help
.map(|proto_help| proto_to_lsp_signature(proto_help))
.map(proto_to_lsp_signature)
.and_then(|lsp_help| SignatureHelp::new(lsp_help, language)))
}
@ -2835,7 +2834,7 @@ impl LspCommand for InlayHints {
proto::InlayHintsResponse {
hints: response
.into_iter()
.map(|response_hint| InlayHints::project_to_proto_hint(response_hint))
.map(InlayHints::project_to_proto_hint)
.collect(),
version: serialize_version(buffer_version),
}
@ -2883,7 +2882,7 @@ impl LspCommand for LinkedEditingRange {
if let LinkedEditingRangeServerCapabilities::Simple(false) = linked_editing_options {
return false;
}
return true;
true
}
fn to_lsp(
@ -2913,7 +2912,8 @@ impl LspCommand for LinkedEditingRange {
) -> Result<Vec<Range<Anchor>>> {
if let Some(lsp::LinkedEditingRanges { mut ranges, .. }) = message {
ranges.sort_by_key(|range| range.start);
let ranges = buffer.read_with(&cx, |buffer, _| {
buffer.read_with(&cx, |buffer, _| {
ranges
.into_iter()
.map(|range| {
@ -2923,9 +2923,7 @@ impl LspCommand for LinkedEditingRange {
buffer.anchor_before(start)..buffer.anchor_after(end)
})
.collect()
});
ranges
})
} else {
Ok(vec![])
}

View file

@ -117,9 +117,7 @@ pub fn lsp_to_proto_signature(lsp_help: lsp::SignatureHelp) -> proto::SignatureH
.into_iter()
.map(|signature| proto::SignatureInformation {
label: signature.label,
documentation: signature
.documentation
.map(|documentation| lsp_to_proto_documentation(documentation)),
documentation: signature.documentation.map(lsp_to_proto_documentation),
parameters: signature
.parameters
.unwrap_or_default()
@ -204,7 +202,7 @@ pub fn proto_to_lsp_signature(proto_help: proto::SignatureHelp) -> lsp::Signatur
}
fn proto_to_lsp_documentation(documentation: proto::Documentation) -> Option<lsp::Documentation> {
let documentation = {
{
Some(match documentation.content? {
documentation::Content::Value(string) => lsp::Documentation::String(string),
documentation::Content::MarkupContent(markup) => {
@ -221,8 +219,7 @@ fn proto_to_lsp_documentation(documentation: proto::Documentation) -> Option<lsp
})
}
})
};
documentation
}
}
#[cfg(test)]

View file

@ -270,11 +270,11 @@ impl LspStore {
}
BufferStoreEvent::BufferChangedFilePath { buffer, old_file } => {
if let Some(old_file) = File::from_dyn(old_file.as_ref()) {
self.unregister_buffer_from_language_servers(&buffer, old_file, cx);
self.unregister_buffer_from_language_servers(buffer, old_file, cx);
}
self.detect_language_for_buffer(&buffer, cx);
self.register_buffer_with_language_servers(&buffer, cx);
self.detect_language_for_buffer(buffer, cx);
self.register_buffer_with_language_servers(buffer, cx);
}
BufferStoreEvent::BufferDropped(_) => {}
}
@ -657,7 +657,7 @@ impl LspStore {
pub async fn execute_code_actions_on_servers(
this: &WeakModel<LspStore>,
adapters_and_servers: &Vec<(Arc<CachedLspAdapter>, Arc<LanguageServer>)>,
adapters_and_servers: &[(Arc<CachedLspAdapter>, Arc<LanguageServer>)],
code_actions: Vec<lsp::CodeActionKind>,
buffer: &Model<Buffer>,
push_to_history: bool,
@ -679,7 +679,7 @@ impl LspStore {
.await?;
for mut action in actions {
Self::try_resolve_code_action(&language_server, &mut action)
Self::try_resolve_code_action(language_server, &mut action)
.await
.context("resolving a formatting code action")?;
@ -733,14 +733,13 @@ impl LspStore {
lang_server: &LanguageServer,
action: &mut CodeAction,
) -> anyhow::Result<()> {
if GetCodeActions::can_resolve_actions(&lang_server.capabilities()) {
if action.lsp_action.data.is_some()
&& (action.lsp_action.command.is_none() || action.lsp_action.edit.is_none())
{
action.lsp_action = lang_server
.request::<lsp::request::CodeActionResolveRequest>(action.lsp_action.clone())
.await?;
}
if GetCodeActions::can_resolve_actions(&lang_server.capabilities())
&& action.lsp_action.data.is_some()
&& (action.lsp_action.command.is_none() || action.lsp_action.edit.is_none())
{
action.lsp_action = lang_server
.request::<lsp::request::CodeActionResolveRequest>(action.lsp_action.clone())
.await?;
}
anyhow::Ok(())
@ -814,10 +813,7 @@ impl LspStore {
})
.await;
if let Err(err) = result {
// TODO: LSP ERROR
return Err(err);
}
result?;
return this.update(&mut cx, |this, _| {
this.last_workspace_edits_by_language_server
@ -1157,7 +1153,7 @@ impl LspStore {
})
} else {
let all_actions_task = self.request_multiple_lsp_locally(
&buffer_handle,
buffer_handle,
Some(range.start),
GetCodeActions {
range: range.clone(),
@ -1280,7 +1276,7 @@ impl LspStore {
let buffer_id = buffer.read(cx).remote_id();
let buffer_snapshot = buffer.read(cx).snapshot();
cx.spawn(move |this, mut cx| async move {
cx.spawn(move |this, cx| async move {
let mut did_resolve = false;
if let Some(client) = client {
for completion_index in completion_indices {
@ -1326,7 +1322,7 @@ impl LspStore {
};
let server = this
.read_with(&mut cx, |this, _| this.language_server_for_id(server_id))
.read_with(&cx, |this, _| this.language_server_for_id(server_id))
.ok()
.flatten();
let Some(server) = server else {
@ -1776,7 +1772,7 @@ impl LspStore {
})
} else {
let all_actions_task = self.request_multiple_lsp_locally(
&buffer,
buffer,
Some(position),
GetHover { position },
cx,
@ -2785,7 +2781,7 @@ impl LspStore {
})
.collect::<FuturesUnordered<_>>();
return cx.spawn(|_, _| async move {
cx.spawn(|_, _| async move {
let mut responses = Vec::with_capacity(response_results.len());
while let Some(response_result) = response_results.next().await {
if let Some(response) = response_result.log_err() {
@ -2793,7 +2789,7 @@ impl LspStore {
}
}
responses
});
})
}
async fn handle_lsp_command<T: LspCommand>(
@ -3279,7 +3275,7 @@ impl LspStore {
if let Some(glob) = Glob::new(relative_glob_pattern).log_err() {
builders
.entry(tree.id())
.or_insert_with(|| GlobSetBuilder::new())
.or_insert_with(GlobSetBuilder::new)
.add(glob);
}
return true;
@ -3674,7 +3670,7 @@ impl LspStore {
let lsp_completion = serde_json::from_slice(&envelope.payload.lsp_completion)?;
let completion = this
.read_with(&mut cx, |this, _| {
.read_with(&cx, |this, _| {
let id = LanguageServerId(envelope.payload.language_server_id as usize);
let Some(server) = this.language_server_for_id(id) else {
return Err(anyhow!("No language server {id}"));
@ -4875,9 +4871,12 @@ impl LspStore {
lsp_name: name.clone(),
};
if let Ok(_) = this.update(&mut cx, |_, cx| {
cx.emit(LspStoreEvent::LanguageServerPrompt(request));
}) {
let did_update = this
.update(&mut cx, |_, cx| {
cx.emit(LspStoreEvent::LanguageServerPrompt(request));
})
.is_ok();
if did_update {
let response = rx.next().await;
Ok(response)
@ -5240,7 +5239,7 @@ impl LspStore {
if file.worktree.read(cx).id() != key.0
|| !self
.languages
.lsp_adapters(&language)
.lsp_adapters(language)
.iter()
.any(|a| a.name == key.1)
{
@ -5272,7 +5271,7 @@ impl LspStore {
lsp::DidOpenTextDocumentParams {
text_document: lsp::TextDocumentItem::new(
uri,
adapter.language_id(&language),
adapter.language_id(language),
version,
initial_snapshot.text(),
),
@ -5498,24 +5497,32 @@ impl LspStore {
) {
let status = self.language_server_statuses.get(&server_id);
let server = self.language_servers.get(&server_id);
if let Some((server, status)) = server.zip(status) {
if let LanguageServerState::Running { server, .. } = server {
for (token, progress) in &status.pending_work {
if let Some(token_to_cancel) = token_to_cancel.as_ref() {
if token != token_to_cancel {
continue;
}
}
if progress.is_cancellable {
server
.notify::<lsp::notification::WorkDoneProgressCancel>(
WorkDoneProgressCancelParams {
token: lsp::NumberOrString::String(token.clone()),
},
)
.ok();
if let Some((LanguageServerState::Running { server, .. }, status)) = server.zip(status) {
for (token, progress) in &status.pending_work {
if let Some(token_to_cancel) = token_to_cancel.as_ref() {
if token != token_to_cancel {
continue;
}
}
if progress.is_cancellable {
server
.notify::<lsp::notification::WorkDoneProgressCancel>(
WorkDoneProgressCancelParams {
token: lsp::NumberOrString::String(token.clone()),
},
)
.ok();
}
if progress.is_cancellable {
server
.notify::<lsp::notification::WorkDoneProgressCancel>(
WorkDoneProgressCancelParams {
token: lsp::NumberOrString::String(token.clone()),
},
)
.ok();
}
}
}
}
@ -5538,7 +5545,7 @@ impl LspStore {
if let Some((file, language)) = File::from_dyn(buffer.file()).zip(buffer.language()) {
let worktree_id = file.worktree_id(cx);
self.languages
.lsp_adapters(&language)
.lsp_adapters(language)
.iter()
.flat_map(|adapter| {
let key = (worktree_id, adapter.name.clone());
@ -5956,7 +5963,7 @@ async fn populate_labels_for_completions(
.zip(labels.into_iter().chain(iter::repeat(None)))
{
let documentation = if let Some(docs) = &lsp_completion.documentation {
Some(prepare_completion_documentation(docs, &language_registry, language.clone()).await)
Some(prepare_completion_documentation(docs, language_registry, language.clone()).await)
} else {
None
};
@ -6089,7 +6096,7 @@ impl DiagnosticSummary {
fn glob_literal_prefix(glob: &str) -> &str {
let mut literal_end = 0;
for (i, part) in glob.split(path::MAIN_SEPARATOR).enumerate() {
if part.contains(&['*', '?', '{', '}']) {
if part.contains(['*', '?', '{', '}']) {
break;
} else {
if i > 0 {
@ -6173,7 +6180,7 @@ impl LspAdapterDelegate for ProjectLspAdapterDelegate {
async fn which(&self, command: &OsStr) -> Option<PathBuf> {
let worktree_abs_path = self.worktree.abs_path();
let shell_path = self.shell_env().await.get("PATH").cloned();
which::which_in(command, shell_path.as_ref(), &worktree_abs_path).ok()
which::which_in(command, shell_path.as_ref(), worktree_abs_path).ok()
}
#[cfg(target_os = "windows")]
@ -6280,10 +6287,10 @@ async fn populate_labels_for_symbols(
fn include_text(server: &lsp::LanguageServer) -> Option<bool> {
match server.capabilities().text_document_sync.as_ref()? {
lsp::TextDocumentSyncCapability::Kind(kind) => match kind {
&lsp::TextDocumentSyncKind::NONE => None,
&lsp::TextDocumentSyncKind::FULL => Some(true),
&lsp::TextDocumentSyncKind::INCREMENTAL => Some(false),
lsp::TextDocumentSyncCapability::Kind(kind) => match *kind {
lsp::TextDocumentSyncKind::NONE => None,
lsp::TextDocumentSyncKind::FULL => Some(true),
lsp::TextDocumentSyncKind::INCREMENTAL => Some(false),
_ => None,
},
lsp::TextDocumentSyncCapability::Options(options) => match options.save.as_ref()? {

View file

@ -49,9 +49,7 @@ pub(super) async fn format_with_prettier(
.ok()?
.await;
let Some((prettier_path, prettier_task)) = prettier_instance else {
return None;
};
let (prettier_path, prettier_task) = prettier_instance?;
let prettier_description = match prettier_path.as_ref() {
Some(path) => format!("prettier at {path:?}"),
@ -262,10 +260,10 @@ fn start_default_prettier(
});
new_default_prettier
})?;
return Ok(new_default_prettier);
Ok(new_default_prettier)
}
ControlFlow::Break(instance) => match instance.prettier {
Some(instance) => return Ok(instance),
Some(instance) => Ok(instance),
None => {
let new_default_prettier = project.update(&mut cx, |project, cx| {
let new_default_prettier =
@ -277,7 +275,7 @@ fn start_default_prettier(
});
new_default_prettier
})?;
return Ok(new_default_prettier);
Ok(new_default_prettier)
}
},
}

View file

@ -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()),

View file

@ -25,6 +25,7 @@ pub struct ProjectSettings {
///
/// The following settings can be overridden for specific language servers:
/// - initialization_options
///
/// To override settings for a language, add an entry for that language server's
/// name to the lsp value.
/// Default: null
@ -335,16 +336,13 @@ impl SettingsObserver {
event: &WorktreeStoreEvent,
cx: &mut ModelContext<Self>,
) {
match event {
WorktreeStoreEvent::WorktreeAdded(worktree) => cx
.subscribe(worktree, |this, worktree, event, cx| match event {
worktree::Event::UpdatedEntries(changes) => {
this.update_local_worktree_settings(&worktree, changes, cx)
}
_ => {}
})
.detach(),
_ => {}
if let WorktreeStoreEvent::WorktreeAdded(worktree) = event {
cx.subscribe(worktree, |this, worktree, event, cx| {
if let worktree::Event::UpdatedEntries(changes) = event {
this.update_local_worktree_settings(&worktree, changes, cx)
}
})
.detach()
}
}

View file

@ -72,10 +72,10 @@ async fn test_symlinks(cx: &mut gpui::TestAppContext) {
}));
let root_link_path = dir.path().join("root_link");
os::unix::fs::symlink(&dir.path().join("root"), &root_link_path).unwrap();
os::unix::fs::symlink(dir.path().join("root"), &root_link_path).unwrap();
os::unix::fs::symlink(
&dir.path().join("root/fennel"),
&dir.path().join("root/finnochio"),
dir.path().join("root/fennel"),
dir.path().join("root/finnochio"),
)
.unwrap();
@ -4699,7 +4699,7 @@ async fn test_multiple_language_server_hovers(cx: &mut gpui::TestAppContext) {
let mut fake_tsx_language_servers = language_registry.register_fake_lsp_adapter(
"tsx",
FakeLspAdapter {
name: &language_server_names[0],
name: language_server_names[0],
capabilities: lsp::ServerCapabilities {
hover_provider: Some(lsp::HoverProviderCapability::Simple(true)),
..lsp::ServerCapabilities::default()
@ -4710,7 +4710,7 @@ async fn test_multiple_language_server_hovers(cx: &mut gpui::TestAppContext) {
let _a = language_registry.register_fake_lsp_adapter(
"tsx",
FakeLspAdapter {
name: &language_server_names[1],
name: language_server_names[1],
capabilities: lsp::ServerCapabilities {
hover_provider: Some(lsp::HoverProviderCapability::Simple(true)),
..lsp::ServerCapabilities::default()
@ -4721,7 +4721,7 @@ async fn test_multiple_language_server_hovers(cx: &mut gpui::TestAppContext) {
let _b = language_registry.register_fake_lsp_adapter(
"tsx",
FakeLspAdapter {
name: &language_server_names[2],
name: language_server_names[2],
capabilities: lsp::ServerCapabilities {
hover_provider: Some(lsp::HoverProviderCapability::Simple(true)),
..lsp::ServerCapabilities::default()
@ -4732,7 +4732,7 @@ async fn test_multiple_language_server_hovers(cx: &mut gpui::TestAppContext) {
let _c = language_registry.register_fake_lsp_adapter(
"tsx",
FakeLspAdapter {
name: &language_server_names[3],
name: language_server_names[3],
capabilities: lsp::ServerCapabilities {
hover_provider: None,
..lsp::ServerCapabilities::default()
@ -4919,7 +4919,7 @@ async fn test_multiple_language_server_actions(cx: &mut gpui::TestAppContext) {
let mut fake_tsx_language_servers = language_registry.register_fake_lsp_adapter(
"tsx",
FakeLspAdapter {
name: &language_server_names[0],
name: language_server_names[0],
capabilities: lsp::ServerCapabilities {
code_action_provider: Some(lsp::CodeActionProviderCapability::Simple(true)),
..lsp::ServerCapabilities::default()
@ -4930,7 +4930,7 @@ async fn test_multiple_language_server_actions(cx: &mut gpui::TestAppContext) {
let _a = language_registry.register_fake_lsp_adapter(
"tsx",
FakeLspAdapter {
name: &language_server_names[1],
name: language_server_names[1],
capabilities: lsp::ServerCapabilities {
code_action_provider: Some(lsp::CodeActionProviderCapability::Simple(true)),
..lsp::ServerCapabilities::default()
@ -4941,7 +4941,7 @@ async fn test_multiple_language_server_actions(cx: &mut gpui::TestAppContext) {
let _b = language_registry.register_fake_lsp_adapter(
"tsx",
FakeLspAdapter {
name: &language_server_names[2],
name: language_server_names[2],
capabilities: lsp::ServerCapabilities {
code_action_provider: Some(lsp::CodeActionProviderCapability::Simple(true)),
..lsp::ServerCapabilities::default()
@ -4952,7 +4952,7 @@ async fn test_multiple_language_server_actions(cx: &mut gpui::TestAppContext) {
let _c = language_registry.register_fake_lsp_adapter(
"tsx",
FakeLspAdapter {
name: &language_server_names[3],
name: language_server_names[3],
capabilities: lsp::ServerCapabilities {
code_action_provider: None,
..lsp::ServerCapabilities::default()

View file

@ -89,7 +89,7 @@ impl SearchQuery {
let query = query.to_string();
let search = AhoCorasickBuilder::new()
.ascii_case_insensitive(!case_sensitive)
.build(&[&query])?;
.build([&query])?;
let inner = SearchInputs {
query: query.into(),
files_to_exclude,
@ -481,7 +481,8 @@ pub fn deserialize_path_matches(glob_set: &str) -> anyhow::Result<PathMatcher> {
let globs = glob_set
.split(',')
.map(str::trim)
.filter_map(|glob_str| (!glob_str.is_empty()).then(|| glob_str.to_owned()))
.filter(|&glob_str| (!glob_str.is_empty()))
.map(|glob_str| glob_str.to_owned())
.collect::<Vec<_>>();
Ok(PathMatcher::new(&globs)?)
}

View file

@ -395,7 +395,7 @@ fn task_lru_comparator(
) -> cmp::Ordering {
lru_score_a
// First, display recently used templates above all.
.cmp(&lru_score_b)
.cmp(lru_score_b)
// Then, ensure more specific sources are displayed first.
.then(task_source_kind_preference(kind_a).cmp(&task_source_kind_preference(kind_b)))
// After that, display first more specific tasks, using more template variables.

View file

@ -60,7 +60,7 @@ impl Project {
let worktree = self.worktrees(cx).next()?;
let worktree = worktree.read(cx);
if worktree.root_entry()?.is_dir() {
return Some(worktree.abs_path().to_path_buf());
Some(worktree.abs_path().to_path_buf())
} else {
None
}
@ -261,7 +261,7 @@ impl Project {
let venv_settings = settings.detect_venv.as_option()?;
venv_settings
.directories
.into_iter()
.iter()
.map(|virtual_environment_name| abs_path.join(virtual_environment_name))
.find(|venv_path| {
let bin_path = venv_path.join("bin");
@ -335,7 +335,7 @@ pub fn wrap_for_ssh(
}
}
if let Some(venv_directory) = venv_directory {
if let Some(str) = shlex::try_quote(venv_directory.to_string_lossy().as_ref()).ok() {
if let Ok(str) = shlex::try_quote(venv_directory.to_string_lossy().as_ref()) {
env_changes.push_str(&format!("PATH={}:$PATH ", str));
}
}
@ -349,7 +349,7 @@ pub fn wrap_for_ssh(
let (program, mut args) = match ssh_command {
SshCommand::DevServer(ssh_command) => {
let mut args = shlex::split(&ssh_command).unwrap_or_default();
let mut args = shlex::split(ssh_command).unwrap_or_default();
let program = args.drain(0..1).next().unwrap_or("ssh".to_string());
(program, args)
}

View file

@ -168,11 +168,10 @@ impl WorktreeStore {
}
let task = self.loading_worktrees.get(&path).unwrap().clone();
cx.background_executor().spawn(async move {
let result = match task.await {
match task.await {
Ok(worktree) => Ok(worktree),
Err(err) => Err(anyhow!("{}", err)),
};
result
}
})
}
@ -549,7 +548,7 @@ impl WorktreeStore {
drop(filters);
})
.detach();
return matching_paths_rx;
matching_paths_rx
}
fn scan_ignored_dir<'a>(
@ -562,7 +561,7 @@ impl WorktreeStore {
output_tx: &'a Sender<oneshot::Receiver<ProjectPath>>,
) -> BoxFuture<'a, Result<()>> {
async move {
let abs_path = snapshot.abs_path().join(&path);
let abs_path = snapshot.abs_path().join(path);
let Some(mut files) = fs
.read_dir(&abs_path)
.await

View file

@ -49,7 +49,7 @@ fn resolve_virtual(path: &Path) -> Option<Arc<Path>> {
continue;
}
}
non_virtual_path.push(&components[i]);
non_virtual_path.push(components[i]);
i += 1;
}
@ -85,7 +85,7 @@ impl YarnPathStore {
path
};
let as_virtual = resolve_virtual(&path);
let as_virtual = resolve_virtual(path);
let Some(path) = as_virtual.or_else(|| is_zip.then(|| Arc::from(path))) else {
return Task::ready(None);
};