diff --git a/Cargo.toml b/Cargo.toml index f326090b51..89aadbcba0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -830,6 +830,7 @@ module_inception = { level = "deny" } question_mark = { level = "deny" } redundant_closure = { level = "deny" } declare_interior_mutable_const = { level = "deny" } +collapsible_if = { level = "warn"} needless_borrow = { level = "warn"} # Individual rules that have violations in the codebase: type_complexity = "allow" diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index b86696d437..0c6658f364 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -249,15 +249,14 @@ impl ToolCall { } if let Some(raw_output) = raw_output { - if self.content.is_empty() { - if let Some(markdown) = markdown_for_raw_output(&raw_output, &language_registry, cx) + if self.content.is_empty() + && let Some(markdown) = markdown_for_raw_output(&raw_output, &language_registry, cx) { self.content .push(ToolCallContent::ContentBlock(ContentBlock::Markdown { markdown, })); } - } self.raw_output = Some(raw_output); } } @@ -430,12 +429,11 @@ impl ContentBlock { language_registry: &Arc, cx: &mut App, ) { - if matches!(self, ContentBlock::Empty) { - if let acp::ContentBlock::ResourceLink(resource_link) = block { + if matches!(self, ContentBlock::Empty) + && let acp::ContentBlock::ResourceLink(resource_link) = block { *self = ContentBlock::ResourceLink { resource_link }; return; } - } let new_content = self.block_string_contents(block); diff --git a/crates/action_log/src/action_log.rs b/crates/action_log/src/action_log.rs index 20ba9586ea..b88dff1f61 100644 --- a/crates/action_log/src/action_log.rs +++ b/crates/action_log/src/action_log.rs @@ -614,11 +614,10 @@ impl ActionLog { false } }); - if tracked_buffer.unreviewed_edits.is_empty() { - if let TrackedBufferStatus::Created { .. } = &mut tracked_buffer.status { + if tracked_buffer.unreviewed_edits.is_empty() + && let TrackedBufferStatus::Created { .. } = &mut tracked_buffer.status { tracked_buffer.status = TrackedBufferStatus::Modified; } - } tracked_buffer.schedule_diff_update(ChangeAuthor::User, cx); } } diff --git a/crates/activity_indicator/src/activity_indicator.rs b/crates/activity_indicator/src/activity_indicator.rs index 090252d338..9550611e27 100644 --- a/crates/activity_indicator/src/activity_indicator.rs +++ b/crates/activity_indicator/src/activity_indicator.rs @@ -458,8 +458,8 @@ impl ActivityIndicator { .map(|r| r.read(cx)) .and_then(Repository::current_job); // Show any long-running git command - if let Some(job_info) = current_job { - if Instant::now() - job_info.start >= GIT_OPERATION_DELAY { + if let Some(job_info) = current_job + && Instant::now() - job_info.start >= GIT_OPERATION_DELAY { return Some(Content { icon: Some( Icon::new(IconName::ArrowCircle) @@ -478,7 +478,6 @@ impl ActivityIndicator { tooltip_message: None, }); } - } // Show any language server installation info. let mut downloading = SmallVec::<[_; 3]>::new(); @@ -740,8 +739,7 @@ impl ActivityIndicator { if let Some(extension_store) = ExtensionStore::try_global(cx).map(|extension_store| extension_store.read(cx)) - { - if let Some(extension_id) = extension_store.outstanding_operations().keys().next() { + && let Some(extension_id) = extension_store.outstanding_operations().keys().next() { return Some(Content { icon: Some( Icon::new(IconName::Download) @@ -755,7 +753,6 @@ impl ActivityIndicator { tooltip_message: None, }); } - } None } diff --git a/crates/agent/src/context.rs b/crates/agent/src/context.rs index 8cdb87ef8d..354c817d0e 100644 --- a/crates/agent/src/context.rs +++ b/crates/agent/src/context.rs @@ -201,8 +201,8 @@ impl FileContextHandle { parse_status.changed().await.log_err(); } - if let Ok(snapshot) = buffer.read_with(cx, |buffer, _| buffer.snapshot()) { - if let Some(outline) = snapshot.outline(None) { + if let Ok(snapshot) = buffer.read_with(cx, |buffer, _| buffer.snapshot()) + && let Some(outline) = snapshot.outline(None) { let items = outline .items .into_iter() @@ -220,7 +220,6 @@ impl FileContextHandle { return Some((context, vec![buffer])); } } - } } } diff --git a/crates/agent/src/context_store.rs b/crates/agent/src/context_store.rs index 60ba5527dc..3aecce9201 100644 --- a/crates/agent/src/context_store.rs +++ b/crates/agent/src/context_store.rs @@ -338,12 +338,11 @@ impl ContextStore { image_task, context_id: self.next_context_id.post_inc(), }); - if self.has_context(&context) { - if remove_if_exists { + if self.has_context(&context) + && remove_if_exists { self.remove_context(&context, cx); return None; } - } self.insert_context(context.clone(), cx); Some(context) diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index a3f903a60d..4ed15b3db3 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -1967,11 +1967,9 @@ impl Thread { if let Some(prev_message) = thread.messages.get(ix - 1) - { - if prev_message.role == Role::Assistant { + && prev_message.role == Role::Assistant { break; } - } } } @@ -2476,14 +2474,13 @@ impl Thread { .ok()?; // Save thread so its summary can be reused later - if let Some(thread) = thread.upgrade() { - if let Ok(Ok(save_task)) = cx.update(|cx| { + if let Some(thread) = thread.upgrade() + && let Ok(Ok(save_task)) = cx.update(|cx| { thread_store .update(cx, |thread_store, cx| thread_store.save_thread(&thread, cx)) }) { save_task.await.log_err(); } - } Some(()) }); @@ -2730,13 +2727,11 @@ impl Thread { window: Option, cx: &mut Context, ) { - if self.all_tools_finished() { - if let Some(ConfiguredModel { model, .. }) = self.configured_model.as_ref() { - if !canceled { + if self.all_tools_finished() + && let Some(ConfiguredModel { model, .. }) = self.configured_model.as_ref() + && !canceled { self.send_to_model(model.clone(), CompletionIntent::ToolResults, window, cx); } - } - } cx.emit(ThreadEvent::ToolFinished { tool_use_id, @@ -2922,12 +2917,11 @@ impl Thread { let buffer_store = project.read(app_cx).buffer_store(); for buffer_handle in buffer_store.read(app_cx).buffers() { let buffer = buffer_handle.read(app_cx); - if buffer.is_dirty() { - if let Some(file) = buffer.file() { + if buffer.is_dirty() + && let Some(file) = buffer.file() { let path = file.path().to_string_lossy().to_string(); unsaved_buffers.push(path); } - } } }) .ok(); @@ -3178,14 +3172,13 @@ impl Thread { .model .max_token_count_for_mode(self.completion_mode().into()); - if let Some(exceeded_error) = &self.exceeded_window_error { - if model.model.id() == exceeded_error.model_id { + if let Some(exceeded_error) = &self.exceeded_window_error + && model.model.id() == exceeded_error.model_id { return Some(TotalTokenUsage { total: exceeded_error.token_count, max, }); } - } let total = self .token_usage_at_last_message() diff --git a/crates/agent/src/thread_store.rs b/crates/agent/src/thread_store.rs index 12c94a522d..0b17f4d329 100644 --- a/crates/agent/src/thread_store.rs +++ b/crates/agent/src/thread_store.rs @@ -581,8 +581,8 @@ impl ThreadStore { return; }; - if protocol.capable(context_server::protocol::ServerCapability::Tools) { - if let Some(response) = protocol + if protocol.capable(context_server::protocol::ServerCapability::Tools) + && let Some(response) = protocol .request::(()) .await .log_err() @@ -609,7 +609,6 @@ impl ThreadStore { .log_err(); } } - } }) .detach(); } @@ -697,14 +696,13 @@ impl SerializedThreadV0_1_0 { let mut messages: Vec = Vec::with_capacity(self.0.messages.len()); for message in self.0.messages { - if message.role == Role::User && !message.tool_results.is_empty() { - if let Some(last_message) = messages.last_mut() { + if message.role == Role::User && !message.tool_results.is_empty() + && let Some(last_message) = messages.last_mut() { debug_assert!(last_message.role == Role::Assistant); last_message.tool_results = message.tool_results; continue; } - } messages.push(message); } diff --git a/crates/agent/src/tool_use.rs b/crates/agent/src/tool_use.rs index 74dfaf9a85..232868c4ee 100644 --- a/crates/agent/src/tool_use.rs +++ b/crates/agent/src/tool_use.rs @@ -112,10 +112,10 @@ impl ToolUseState { }, ); - if let Some(window) = &mut window { - if let Some(tool) = this.tools.read(cx).tool(tool_use, cx) { - if let Some(output) = tool_result.output.clone() { - if let Some(card) = tool.deserialize_card( + if let Some(window) = &mut window + && let Some(tool) = this.tools.read(cx).tool(tool_use, cx) + && let Some(output) = tool_result.output.clone() + && let Some(card) = tool.deserialize_card( output, project.clone(), window, @@ -123,9 +123,6 @@ impl ToolUseState { ) { this.tool_result_cards.insert(tool_use_id, card); } - } - } - } } } } diff --git a/crates/agent2/src/thread.rs b/crates/agent2/src/thread.rs index f0b5d2f08a..2776b106a5 100644 --- a/crates/agent2/src/thread.rs +++ b/crates/agent2/src/thread.rs @@ -1037,13 +1037,12 @@ impl Thread { log::info!("Running tool {}", tool_use.name); Some(cx.foreground_executor().spawn(async move { let tool_result = tool_result.await.and_then(|output| { - if let LanguageModelToolResultContent::Image(_) = &output.llm_output { - if !supports_images { + if let LanguageModelToolResultContent::Image(_) = &output.llm_output + && !supports_images { return Err(anyhow!( "Attempted to read an image, but this model doesn't support it.", )); } - } Ok(output) }); diff --git a/crates/agent2/src/tools/edit_file_tool.rs b/crates/agent2/src/tools/edit_file_tool.rs index 8ebd2936a5..be767bcef2 100644 --- a/crates/agent2/src/tools/edit_file_tool.rs +++ b/crates/agent2/src/tools/edit_file_tool.rs @@ -156,14 +156,13 @@ impl EditFileTool { // It's also possible that the global config dir is configured to be inside the project, // so check for that edge case too. - if let Ok(canonical_path) = std::fs::canonicalize(&input.path) { - if canonical_path.starts_with(paths::config_dir()) { + if let Ok(canonical_path) = std::fs::canonicalize(&input.path) + && canonical_path.starts_with(paths::config_dir()) { return event_stream.authorize( format!("{} (global settings)", input.display_description), cx, ); } - } // Check if path is inside the global config directory // First check if it's already inside project - if not, try to canonicalize diff --git a/crates/agent2/src/tools/grep_tool.rs b/crates/agent2/src/tools/grep_tool.rs index e5d92b3c1d..6d7c05d211 100644 --- a/crates/agent2/src/tools/grep_tool.rs +++ b/crates/agent2/src/tools/grep_tool.rs @@ -179,15 +179,14 @@ impl AgentTool for GrepTool { // Check if this file should be excluded based on its worktree settings if let Ok(Some(project_path)) = project.read_with(cx, |project, cx| { project.find_project_path(&path, cx) - }) { - if cx.update(|cx| { + }) + && cx.update(|cx| { let worktree_settings = WorktreeSettings::get(Some((&project_path).into()), cx); worktree_settings.is_path_excluded(&project_path.path) || worktree_settings.is_path_private(&project_path.path) }).unwrap_or(false) { continue; } - } while *parse_status.borrow() != ParseStatus::Idle { parse_status.changed().await?; @@ -275,12 +274,11 @@ impl AgentTool for GrepTool { output.extend(snapshot.text_for_range(range)); output.push_str("\n```\n"); - if let Some(ancestor_range) = ancestor_range { - if end_row < ancestor_range.end.row { + if let Some(ancestor_range) = ancestor_range + && end_row < ancestor_range.end.row { let remaining_lines = ancestor_range.end.row - end_row; writeln!(output, "\n{} lines remaining in ancestor node. Read the file to see all.", remaining_lines)?; } - } matches_found += 1; } diff --git a/crates/agent_servers/src/claude.rs b/crates/agent_servers/src/claude.rs index 7034d6fbce..ee0a231625 100644 --- a/crates/agent_servers/src/claude.rs +++ b/crates/agent_servers/src/claude.rs @@ -203,15 +203,14 @@ impl AgentConnection for ClaudeAgentConnection { .await } - if let Some(status) = child.status().await.log_err() { - if let Some(thread) = thread_rx.recv().await.ok() { + if let Some(status) = child.status().await.log_err() + && let Some(thread) = thread_rx.recv().await.ok() { thread .update(cx, |thread, cx| { thread.emit_server_exited(status, cx); }) .ok(); } - } } }); diff --git a/crates/agent_settings/src/agent_settings.rs b/crates/agent_settings/src/agent_settings.rs index fd38ba1f7f..66c4fbf7f9 100644 --- a/crates/agent_settings/src/agent_settings.rs +++ b/crates/agent_settings/src/agent_settings.rs @@ -116,16 +116,14 @@ pub struct LanguageModelParameters { impl LanguageModelParameters { pub fn matches(&self, model: &Arc) -> bool { - if let Some(provider) = &self.provider { - if provider.0 != model.provider_id().0 { + if let Some(provider) = &self.provider + && provider.0 != model.provider_id().0 { return false; } - } - if let Some(setting_model) = &self.model { - if *setting_model != model.id().0 { + if let Some(setting_model) = &self.model + && *setting_model != model.id().0 { return false; } - } true } } diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 370dae53e4..2aa2003e81 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -371,8 +371,8 @@ impl AcpThreadView { let provider_id = provider_id.clone(); let this = this.clone(); move |_, ev, window, cx| { - if let language_model::Event::ProviderStateChanged(updated_provider_id) = &ev { - if &provider_id == updated_provider_id { + if let language_model::Event::ProviderStateChanged(updated_provider_id) = &ev + && &provider_id == updated_provider_id { this.update(cx, |this, cx| { this.thread_state = Self::initial_state( agent.clone(), @@ -385,7 +385,6 @@ impl AcpThreadView { }) .ok(); } - } } }); @@ -547,12 +546,11 @@ impl AcpThreadView { } fn send(&mut self, window: &mut Window, cx: &mut Context) { - if let Some(thread) = self.thread() { - if thread.read(cx).status() != ThreadStatus::Idle { + if let Some(thread) = self.thread() + && thread.read(cx).status() != ThreadStatus::Idle { self.stop_current_and_send_new_message(window, cx); return; } - } let contents = self .message_editor @@ -628,8 +626,8 @@ impl AcpThreadView { return; }; - if let Some(index) = self.editing_message.take() { - if let Some(editor) = self + if let Some(index) = self.editing_message.take() + && let Some(editor) = self .entry_view_state .read(cx) .entry(index) @@ -646,8 +644,7 @@ impl AcpThreadView { editor.set_message(user_message.chunks.clone(), window, cx); } }) - } - }; + }; self.focus_handle(cx).focus(window); cx.notify(); } @@ -3265,8 +3262,7 @@ impl AcpThreadView { }) }) .log_err() - { - if let Some(pop_up) = screen_window.entity(cx).log_err() { + && let Some(pop_up) = screen_window.entity(cx).log_err() { self.notification_subscriptions .entry(screen_window) .or_insert_with(Vec::new) @@ -3311,17 +3307,15 @@ impl AcpThreadView { let pop_up_weak = pop_up.downgrade(); cx.observe_window_activation(window, move |_, window, cx| { - if window.is_window_active() { - if let Some(pop_up) = pop_up_weak.upgrade() { + if window.is_window_active() + && let Some(pop_up) = pop_up_weak.upgrade() { pop_up.update(cx, |_, cx| { cx.emit(AgentNotificationEvent::Dismissed); }); } - } }) }); } - } } fn dismiss_notifications(&mut self, cx: &mut Context) { diff --git a/crates/agent_ui/src/active_thread.rs b/crates/agent_ui/src/active_thread.rs index d2f448635e..2d7e3d91db 100644 --- a/crates/agent_ui/src/active_thread.rs +++ b/crates/agent_ui/src/active_thread.rs @@ -1072,8 +1072,8 @@ impl ActiveThread { } ThreadEvent::MessageEdited(message_id) => { self.clear_last_error(); - if let Some(index) = self.messages.iter().position(|id| id == message_id) { - if let Some(rendered_message) = self.thread.update(cx, |thread, cx| { + if let Some(index) = self.messages.iter().position(|id| id == message_id) + && let Some(rendered_message) = self.thread.update(cx, |thread, cx| { thread.message(*message_id).map(|message| { let mut rendered_message = RenderedMessage { language_registry: self.language_registry.clone(), @@ -1092,7 +1092,6 @@ impl ActiveThread { self.save_thread(cx); cx.notify(); } - } } ThreadEvent::MessageDeleted(message_id) => { self.deleted_message(message_id); @@ -1272,8 +1271,7 @@ impl ActiveThread { }) }) .log_err() - { - if let Some(pop_up) = screen_window.entity(cx).log_err() { + && let Some(pop_up) = screen_window.entity(cx).log_err() { self.notification_subscriptions .entry(screen_window) .or_insert_with(Vec::new) @@ -1318,17 +1316,15 @@ impl ActiveThread { let pop_up_weak = pop_up.downgrade(); cx.observe_window_activation(window, move |_, window, cx| { - if window.is_window_active() { - if let Some(pop_up) = pop_up_weak.upgrade() { + if window.is_window_active() + && let Some(pop_up) = pop_up_weak.upgrade() { pop_up.update(cx, |_, cx| { cx.emit(AgentNotificationEvent::Dismissed); }); } - } }) }); } - } } /// Spawns a task to save the active thread. @@ -2269,8 +2265,7 @@ impl ActiveThread { let mut error = None; if let Some(last_restore_checkpoint) = self.thread.read(cx).last_restore_checkpoint() - { - if last_restore_checkpoint.message_id() == message_id { + && last_restore_checkpoint.message_id() == message_id { match last_restore_checkpoint { LastRestoreCheckpoint::Pending { .. } => is_pending = true, LastRestoreCheckpoint::Error { error: err, .. } => { @@ -2278,7 +2273,6 @@ impl ActiveThread { } } } - } let restore_checkpoint_button = Button::new(("restore-checkpoint", ix), "Restore Checkpoint") diff --git a/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs b/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs index 32360dd56e..d34a132596 100644 --- a/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs +++ b/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs @@ -163,11 +163,10 @@ impl ConfigurationSource { .read(cx) .text(cx); let settings = serde_json_lenient::from_str::(&text)?; - if let Some(settings_validator) = settings_validator { - if let Err(error) = settings_validator.validate(&settings) { + if let Some(settings_validator) = settings_validator + && let Err(error) = settings_validator.validate(&settings) { return Err(anyhow::anyhow!(error.to_string())); } - } Ok(( id.clone(), ContextServerSettings::Extension { @@ -716,25 +715,22 @@ fn wait_for_context_server( project::context_server_store::Event::ServerStatusChanged { server_id, status } => { match status { ContextServerStatus::Running => { - if server_id == &context_server_id { - if let Some(tx) = tx.lock().unwrap().take() { + if server_id == &context_server_id + && let Some(tx) = tx.lock().unwrap().take() { let _ = tx.send(Ok(())); } - } } ContextServerStatus::Stopped => { - if server_id == &context_server_id { - if let Some(tx) = tx.lock().unwrap().take() { + if server_id == &context_server_id + && let Some(tx) = tx.lock().unwrap().take() { let _ = tx.send(Err("Context server stopped running".into())); } - } } ContextServerStatus::Error(error) => { - if server_id == &context_server_id { - if let Some(tx) = tx.lock().unwrap().take() { + if server_id == &context_server_id + && let Some(tx) = tx.lock().unwrap().take() { let _ = tx.send(Err(error.clone())); } - } } _ => {} } diff --git a/crates/agent_ui/src/agent_configuration/tool_picker.rs b/crates/agent_ui/src/agent_configuration/tool_picker.rs index 8f1e0d71c0..07f10d7c4d 100644 --- a/crates/agent_ui/src/agent_configuration/tool_picker.rs +++ b/crates/agent_ui/src/agent_configuration/tool_picker.rs @@ -191,11 +191,10 @@ impl PickerDelegate for ToolPickerDelegate { BTreeMap::default(); for item in all_items.iter() { - if let PickerItem::Tool { server_id, name } = item.clone() { - if name.contains(&query) { + if let PickerItem::Tool { server_id, name } = item.clone() + && name.contains(&query) { tools_by_provider.entry(server_id).or_default().push(name); } - } } let mut items = Vec::new(); diff --git a/crates/agent_ui/src/agent_diff.rs b/crates/agent_ui/src/agent_diff.rs index b010f8a424..7b10ce3c12 100644 --- a/crates/agent_ui/src/agent_diff.rs +++ b/crates/agent_ui/src/agent_diff.rs @@ -1043,8 +1043,8 @@ impl ToolbarItemView for AgentDiffToolbar { return self.location(cx); } - if let Some(editor) = item.act_as::(cx) { - if editor.read(cx).mode().is_full() { + if let Some(editor) = item.act_as::(cx) + && editor.read(cx).mode().is_full() { let agent_diff = AgentDiff::global(cx); self.active_item = Some(AgentDiffToolbarItem::Editor { @@ -1055,7 +1055,6 @@ impl ToolbarItemView for AgentDiffToolbar { return self.location(cx); } - } } self.active_item = None; @@ -1538,8 +1537,8 @@ impl AgentDiff { ) { match event { workspace::Event::ItemAdded { item } => { - if let Some(editor) = item.downcast::() { - if let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx) { + if let Some(editor) = item.downcast::() + && let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx) { self.register_editor( workspace.downgrade(), buffer.clone(), @@ -1548,7 +1547,6 @@ impl AgentDiff { cx, ); } - } } _ => {} } @@ -1850,8 +1848,8 @@ impl AgentDiff { let thread = thread.upgrade()?; - if let PostReviewState::AllReviewed = review(&editor, &thread, window, cx) { - if let Some(curr_buffer) = editor.read(cx).buffer().read(cx).as_singleton() { + if let PostReviewState::AllReviewed = review(&editor, &thread, window, cx) + && let Some(curr_buffer) = editor.read(cx).buffer().read(cx).as_singleton() { let changed_buffers = thread.action_log(cx).read(cx).changed_buffers(cx); let mut keys = changed_buffers.keys().cycle(); @@ -1867,7 +1865,6 @@ impl AgentDiff { return Some(task); } } - } return Some(Task::ready(Ok(()))); } diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index cb354222b6..295184f8fb 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -1398,15 +1398,13 @@ impl AgentPanel { if LanguageModelRegistry::read_global(cx) .default_model() .map_or(true, |model| model.provider.id() != provider.id()) - { - if let Some(model) = provider.default_model(cx) { + && let Some(model) = provider.default_model(cx) { update_settings_file::( self.fs.clone(), cx, move |settings, _| settings.set_model(model), ); } - } self.new_thread(&NewThread::default(), window, cx); if let Some((thread, model)) = diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index 23e04266db..ed0de4f2dd 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -352,13 +352,12 @@ impl CodegenAlternative { event: &multi_buffer::Event, cx: &mut Context, ) { - if let multi_buffer::Event::TransactionUndone { transaction_id } = event { - if self.transformation_transaction_id == Some(*transaction_id) { + if let multi_buffer::Event::TransactionUndone { transaction_id } = event + && self.transformation_transaction_id == Some(*transaction_id) { self.transformation_transaction_id = None; self.generation = Task::ready(()); cx.emit(CodegenEvent::Undone); } - } } pub fn last_equal_ranges(&self) -> &[Range] { @@ -576,8 +575,8 @@ impl CodegenAlternative { let mut lines = chunk.split('\n').peekable(); while let Some(line) = lines.next() { new_text.push_str(line); - if line_indent.is_none() { - if let Some(non_whitespace_ch_ix) = + if line_indent.is_none() + && let Some(non_whitespace_ch_ix) = new_text.find(|ch: char| !ch.is_whitespace()) { line_indent = Some(non_whitespace_ch_ix); @@ -608,7 +607,6 @@ impl CodegenAlternative { &indent_str.repeat(corrected_indent_len), ); } - } if line_indent.is_some() { let char_ops = diff.push_new(&new_text); diff --git a/crates/agent_ui/src/context_strip.rs b/crates/agent_ui/src/context_strip.rs index 51ed3a5e11..9dad66014a 100644 --- a/crates/agent_ui/src/context_strip.rs +++ b/crates/agent_ui/src/context_strip.rs @@ -368,11 +368,10 @@ impl ContextStrip { _window: &mut Window, cx: &mut Context, ) { - if let Some(suggested) = self.suggested_context(cx) { - if self.is_suggested_focused(&self.added_contexts(cx)) { + if let Some(suggested) = self.suggested_context(cx) + && self.is_suggested_focused(&self.added_contexts(cx)) { self.add_suggested_context(&suggested, cx); } - } } fn add_suggested_context(&mut self, suggested: &SuggestedContext, cx: &mut Context) { diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index 781e242fba..5f6fe0d987 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -182,8 +182,8 @@ impl InlineAssistant { match event { workspace::Event::UserSavedItem { item, .. } => { // When the user manually saves an editor, automatically accepts all finished transformations. - if let Some(editor) = item.upgrade().and_then(|item| item.act_as::(cx)) { - if let Some(editor_assists) = self.assists_by_editor.get(&editor.downgrade()) { + if let Some(editor) = item.upgrade().and_then(|item| item.act_as::(cx)) + && let Some(editor_assists) = self.assists_by_editor.get(&editor.downgrade()) { for assist_id in editor_assists.assist_ids.clone() { let assist = &self.assists[&assist_id]; if let CodegenStatus::Done = assist.codegen.read(cx).status(cx) { @@ -191,7 +191,6 @@ impl InlineAssistant { } } } - } } workspace::Event::ItemAdded { item } => { self.register_workspace_item(&workspace, item.as_ref(), window, cx); @@ -342,14 +341,13 @@ impl InlineAssistant { ) .await .ok(); - if let Some(answer) = answer { - if answer == 0 { + if let Some(answer) = answer + && answer == 0 { cx.update(|window, cx| { window.dispatch_action(Box::new(OpenSettings), cx) }) .ok(); } - } anyhow::Ok(()) }) .detach_and_log_err(cx); @@ -435,12 +433,11 @@ impl InlineAssistant { } } - if let Some(prev_selection) = selections.last_mut() { - if selection.start <= prev_selection.end { + if let Some(prev_selection) = selections.last_mut() + && selection.start <= prev_selection.end { prev_selection.end = selection.end; continue; } - } let latest_selection = newest_selection.get_or_insert_with(|| selection.clone()); if selection.id > latest_selection.id { @@ -985,15 +982,14 @@ impl InlineAssistant { EditorEvent::SelectionsChanged { .. } => { for assist_id in editor_assists.assist_ids.clone() { let assist = &self.assists[&assist_id]; - if let Some(decorations) = assist.decorations.as_ref() { - if decorations + if let Some(decorations) = assist.decorations.as_ref() + && decorations .prompt_editor .focus_handle(cx) .is_focused(window) { return; } - } } editor_assists.scroll_lock = None; @@ -1503,21 +1499,18 @@ impl InlineAssistant { window: &mut Window, cx: &mut App, ) -> Option { - if let Some(terminal_panel) = workspace.panel::(cx) { - if terminal_panel + if let Some(terminal_panel) = workspace.panel::(cx) + && terminal_panel .read(cx) .focus_handle(cx) .contains_focused(window, cx) - { - if let Some(terminal_view) = terminal_panel.read(cx).pane().and_then(|pane| { + && let Some(terminal_view) = terminal_panel.read(cx).pane().and_then(|pane| { pane.read(cx) .active_item() .and_then(|t| t.downcast::()) }) { return Some(InlineAssistTarget::Terminal(terminal_view)); } - } - } let context_editor = agent_panel .and_then(|panel| panel.read(cx).active_context_editor()) @@ -1741,9 +1734,9 @@ impl InlineAssist { return; }; - if let CodegenStatus::Error(error) = codegen.read(cx).status(cx) { - if assist.decorations.is_none() { - if let Some(workspace) = assist.workspace.upgrade() { + if let CodegenStatus::Error(error) = codegen.read(cx).status(cx) + && assist.decorations.is_none() + && let Some(workspace) = assist.workspace.upgrade() { let error = format!("Inline assistant error: {}", error); workspace.update(cx, |workspace, cx| { struct InlineAssistantError; @@ -1756,8 +1749,6 @@ impl InlineAssist { workspace.show_toast(Toast::new(id, error), cx); }) } - } - } if assist.decorations.is_none() { this.finish_assist(assist_id, false, window, cx); @@ -1821,19 +1812,17 @@ impl CodeActionProvider for AssistantCodeActionProvider { has_diagnostics = true; } if has_diagnostics { - if let Some(symbols_containing_start) = snapshot.symbols_containing(range.start, None) { - if let Some(symbol) = symbols_containing_start.last() { + if let Some(symbols_containing_start) = snapshot.symbols_containing(range.start, None) + && let Some(symbol) = symbols_containing_start.last() { range.start = cmp::min(range.start, symbol.range.start.to_point(&snapshot)); range.end = cmp::max(range.end, symbol.range.end.to_point(&snapshot)); } - } - if let Some(symbols_containing_end) = snapshot.symbols_containing(range.end, None) { - if let Some(symbol) = symbols_containing_end.last() { + if let Some(symbols_containing_end) = snapshot.symbols_containing(range.end, None) + && let Some(symbol) = symbols_containing_end.last() { range.start = cmp::min(range.start, symbol.range.start.to_point(&snapshot)); range.end = cmp::max(range.end, symbol.range.end.to_point(&snapshot)); } - } Task::ready(Ok(vec![CodeAction { server_id: language::LanguageServerId(0), diff --git a/crates/agent_ui/src/terminal_inline_assistant.rs b/crates/agent_ui/src/terminal_inline_assistant.rs index bcbc308c99..797df2a617 100644 --- a/crates/agent_ui/src/terminal_inline_assistant.rs +++ b/crates/agent_ui/src/terminal_inline_assistant.rs @@ -388,8 +388,8 @@ impl TerminalInlineAssistant { window: &mut Window, cx: &mut App, ) { - if let Some(assist) = self.assists.get_mut(&assist_id) { - if let Some(prompt_editor) = assist.prompt_editor.as_ref().cloned() { + if let Some(assist) = self.assists.get_mut(&assist_id) + && let Some(prompt_editor) = assist.prompt_editor.as_ref().cloned() { assist .terminal .update(cx, |terminal, cx| { @@ -402,7 +402,6 @@ impl TerminalInlineAssistant { }) .log_err(); } - } } } @@ -450,9 +449,9 @@ impl TerminalInlineAssist { return; }; - if let CodegenStatus::Error(error) = &codegen.read(cx).status { - if assist.prompt_editor.is_none() { - if let Some(workspace) = assist.workspace.upgrade() { + if let CodegenStatus::Error(error) = &codegen.read(cx).status + && assist.prompt_editor.is_none() + && let Some(workspace) = assist.workspace.upgrade() { let error = format!("Terminal inline assistant error: {}", error); workspace.update(cx, |workspace, cx| { @@ -466,8 +465,6 @@ impl TerminalInlineAssist { workspace.show_toast(Toast::new(id, error), cx); }) } - } - } if assist.prompt_editor.is_none() { this.finish_assist(assist_id, false, false, window, cx); diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index 376d3c54fd..903dee879c 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -745,8 +745,7 @@ impl TextThreadEditor { ) { if let Some(invoked_slash_command) = self.context.read(cx).invoked_slash_command(&command_id) - { - if let InvokedSlashCommandStatus::Finished = invoked_slash_command.status { + && let InvokedSlashCommandStatus::Finished = invoked_slash_command.status { let run_commands_in_ranges = invoked_slash_command.run_commands_in_ranges.clone(); for range in run_commands_in_ranges { let commands = self.context.update(cx, |context, cx| { @@ -769,7 +768,6 @@ impl TextThreadEditor { } } } - } self.editor.update(cx, |editor, cx| { if let Some(invoked_slash_command) = diff --git a/crates/agent_ui/src/thread_history.rs b/crates/agent_ui/src/thread_history.rs index 66afe2c2c5..b7028f71dc 100644 --- a/crates/agent_ui/src/thread_history.rs +++ b/crates/agent_ui/src/thread_history.rs @@ -166,15 +166,14 @@ impl ThreadHistory { this.all_entries.len().saturating_sub(1), cx, ); - } else if let Some(prev_id) = previously_selected_entry { - if let Some(new_ix) = this + } else if let Some(prev_id) = previously_selected_entry + && let Some(new_ix) = this .all_entries .iter() .position(|probe| probe.id() == prev_id) { this.set_selected_entry_index(new_ix, cx); } - } } SearchState::Searching { query, .. } | SearchState::Searched { query, .. } => { this.search(query.clone(), cx); diff --git a/crates/assistant_context/src/assistant_context.rs b/crates/assistant_context/src/assistant_context.rs index 06abbad39f..1649e79963 100644 --- a/crates/assistant_context/src/assistant_context.rs +++ b/crates/assistant_context/src/assistant_context.rs @@ -1076,8 +1076,8 @@ impl AssistantContext { timestamp, .. } => { - if let Some(slash_command) = self.invoked_slash_commands.get_mut(&id) { - if timestamp > slash_command.timestamp { + if let Some(slash_command) = self.invoked_slash_commands.get_mut(&id) + && timestamp > slash_command.timestamp { slash_command.timestamp = timestamp; match error_message { Some(message) => { @@ -1090,7 +1090,6 @@ impl AssistantContext { } cx.emit(ContextEvent::InvokedSlashCommandChanged { command_id: id }); } - } } ContextOperation::BufferOperation(_) => unreachable!(), } @@ -1368,11 +1367,10 @@ impl AssistantContext { continue; } - if let Some(last_anchor) = last_anchor { - if message.id == last_anchor { + if let Some(last_anchor) = last_anchor + && message.id == last_anchor { hit_last_anchor = true; } - } new_anchor_needs_caching = new_anchor_needs_caching || (invalidated_caches.contains(&message.id) && anchors.contains(&message.id)); @@ -1406,11 +1404,10 @@ impl AssistantContext { if !self.pending_completions.is_empty() { return; } - if let Some(cache_configuration) = cache_configuration { - if !cache_configuration.should_speculate { + if let Some(cache_configuration) = cache_configuration + && !cache_configuration.should_speculate { return; } - } let request = { let mut req = self.to_completion_request(Some(model), cx); @@ -1552,8 +1549,8 @@ impl AssistantContext { }) .map(ToOwned::to_owned) .collect::>(); - if let Some(command) = self.slash_commands.command(name, cx) { - if !command.requires_argument() || !arguments.is_empty() { + if let Some(command) = self.slash_commands.command(name, cx) + && (!command.requires_argument() || !arguments.is_empty()) { let start_ix = offset + command_line.name.start - 1; let end_ix = offset + command_line @@ -1571,7 +1568,6 @@ impl AssistantContext { updated.push(pending_command.clone()); new_commands.push(pending_command); } - } } offset = lines.offset(); @@ -1799,15 +1795,14 @@ impl AssistantContext { }); let end = this.buffer.read(cx).anchor_before(insert_position); - if run_commands_in_text { - if let Some(invoked_slash_command) = + if run_commands_in_text + && let Some(invoked_slash_command) = this.invoked_slash_commands.get_mut(&command_id) { invoked_slash_command .run_commands_in_ranges .push(start..end); } - } } SlashCommandEvent::EndSection => { if let Some(pending_section) = pending_section_stack.pop() { @@ -2741,11 +2736,10 @@ impl AssistantContext { } this.read_with(cx, |this, _cx| { - if let Some(summary) = this.summary.content() { - if summary.text.is_empty() { + if let Some(summary) = this.summary.content() + && summary.text.is_empty() { bail!("Model generated an empty summary"); } - } Ok(()) })??; @@ -2924,8 +2918,8 @@ impl AssistantContext { fs.create_dir(contexts_dir().as_ref()).await?; // rename before write ensures that only one file exists - if let Some(old_path) = old_path.as_ref() { - if new_path.as_path() != old_path.as_ref() { + if let Some(old_path) = old_path.as_ref() + && new_path.as_path() != old_path.as_ref() { fs.rename( old_path, &new_path, @@ -2936,7 +2930,6 @@ impl AssistantContext { ) .await?; } - } // update path before write in case it fails this.update(cx, { diff --git a/crates/assistant_context/src/context_store.rs b/crates/assistant_context/src/context_store.rs index 622d8867a7..3406405458 100644 --- a/crates/assistant_context/src/context_store.rs +++ b/crates/assistant_context/src/context_store.rs @@ -894,8 +894,8 @@ impl ContextStore { return; }; - if protocol.capable(context_server::protocol::ServerCapability::Prompts) { - if let Some(response) = protocol + if protocol.capable(context_server::protocol::ServerCapability::Prompts) + && let Some(response) = protocol .request::(()) .await .log_err() @@ -922,7 +922,6 @@ impl ContextStore { }) .log_err(); } - } }) .detach(); } diff --git a/crates/assistant_slash_commands/src/context_server_command.rs b/crates/assistant_slash_commands/src/context_server_command.rs index 15f3901bfb..a1d3760c0d 100644 --- a/crates/assistant_slash_commands/src/context_server_command.rs +++ b/crates/assistant_slash_commands/src/context_server_command.rs @@ -39,11 +39,10 @@ impl SlashCommand for ContextServerSlashCommand { fn label(&self, cx: &App) -> language::CodeLabel { let mut parts = vec![self.prompt.name.as_str()]; - if let Some(args) = &self.prompt.arguments { - if let Some(arg) = args.first() { + if let Some(args) = &self.prompt.arguments + && let Some(arg) = args.first() { parts.push(arg.name.as_str()); } - } create_label_for_command(parts[0], &parts[1..], cx) } diff --git a/crates/assistant_slash_commands/src/delta_command.rs b/crates/assistant_slash_commands/src/delta_command.rs index 8c840c17b2..16532accd6 100644 --- a/crates/assistant_slash_commands/src/delta_command.rs +++ b/crates/assistant_slash_commands/src/delta_command.rs @@ -66,8 +66,7 @@ impl SlashCommand for DeltaSlashCommand { .metadata .as_ref() .and_then(|value| serde_json::from_value::(value.clone()).ok()) - { - if paths.insert(metadata.path.clone()) { + && paths.insert(metadata.path.clone()) { file_command_old_outputs.push( context_buffer .as_rope() @@ -83,7 +82,6 @@ impl SlashCommand for DeltaSlashCommand { cx, )); } - } } cx.background_spawn(async move { @@ -95,10 +93,9 @@ impl SlashCommand for DeltaSlashCommand { .into_iter() .zip(file_command_new_outputs) { - if let Ok(new_output) = new_output { - if let Ok(new_output) = SlashCommandOutput::from_event_stream(new_output).await - { - if let Some(file_command_range) = new_output.sections.first() { + if let Ok(new_output) = new_output + && let Ok(new_output) = SlashCommandOutput::from_event_stream(new_output).await + && let Some(file_command_range) = new_output.sections.first() { let new_text = &new_output.text[file_command_range.range.clone()]; if old_text.chars().ne(new_text.chars()) { changes_detected = true; @@ -114,8 +111,6 @@ impl SlashCommand for DeltaSlashCommand { output.text.push_str(&new_output.text); } } - } - } } anyhow::ensure!(changes_detected, "no new changes detected"); diff --git a/crates/assistant_slash_commands/src/diagnostics_command.rs b/crates/assistant_slash_commands/src/diagnostics_command.rs index 31014f8fb8..6927455cd6 100644 --- a/crates/assistant_slash_commands/src/diagnostics_command.rs +++ b/crates/assistant_slash_commands/src/diagnostics_command.rs @@ -280,11 +280,10 @@ fn collect_diagnostics( let mut project_summary = DiagnosticSummary::default(); for (project_path, path, summary) in diagnostic_summaries { - if let Some(path_matcher) = &options.path_matcher { - if !path_matcher.is_match(&path) { + if let Some(path_matcher) = &options.path_matcher + && !path_matcher.is_match(&path) { continue; } - } project_summary.error_count += summary.error_count; if options.include_warnings { diff --git a/crates/assistant_slash_commands/src/tab_command.rs b/crates/assistant_slash_commands/src/tab_command.rs index ca7601bc4c..4cf591df23 100644 --- a/crates/assistant_slash_commands/src/tab_command.rs +++ b/crates/assistant_slash_commands/src/tab_command.rs @@ -195,17 +195,14 @@ fn tab_items_for_queries( } for editor in workspace.items_of_type::(cx) { - if let Some(buffer) = editor.read(cx).buffer().read(cx).as_singleton() { - if let Some(timestamp) = + if let Some(buffer) = editor.read(cx).buffer().read(cx).as_singleton() + && let Some(timestamp) = timestamps_by_entity_id.get(&editor.entity_id()) - { - if visited_buffers.insert(buffer.read(cx).remote_id()) { + && visited_buffers.insert(buffer.read(cx).remote_id()) { let snapshot = buffer.read(cx).snapshot(); let full_path = snapshot.resolve_file_path(cx, true); open_buffers.push((full_path, snapshot, *timestamp)); } - } - } } Ok(open_buffers) diff --git a/crates/assistant_tool/src/tool_schema.rs b/crates/assistant_tool/src/tool_schema.rs index 7b48f93ba6..8b7e414eb7 100644 --- a/crates/assistant_tool/src/tool_schema.rs +++ b/crates/assistant_tool/src/tool_schema.rs @@ -24,8 +24,8 @@ pub fn adapt_schema_to_format( fn preprocess_json_schema(json: &mut Value) -> Result<()> { // `additionalProperties` defaults to `false` unless explicitly specified. // This prevents models from hallucinating tool parameters. - if let Value::Object(obj) = json { - if matches!(obj.get("type"), Some(Value::String(s)) if s == "object") { + if let Value::Object(obj) = json + && matches!(obj.get("type"), Some(Value::String(s)) if s == "object") { if !obj.contains_key("additionalProperties") { obj.insert("additionalProperties".to_string(), Value::Bool(false)); } @@ -35,7 +35,6 @@ fn preprocess_json_schema(json: &mut Value) -> Result<()> { obj.insert("properties".to_string(), Value::Object(Default::default())); } } - } Ok(()) } @@ -59,11 +58,10 @@ fn adapt_to_json_schema_subset(json: &mut Value) -> Result<()> { ("optional", |value| value.is_boolean()), ]; for (key, predicate) in KEYS_TO_REMOVE { - if let Some(value) = obj.get(key) { - if predicate(value) { + if let Some(value) = obj.get(key) + && predicate(value) { obj.remove(key); } - } } // If a type is not specified for an input parameter, add a default type @@ -77,13 +75,12 @@ fn adapt_to_json_schema_subset(json: &mut Value) -> Result<()> { } // Handle oneOf -> anyOf conversion - if let Some(subschemas) = obj.get_mut("oneOf") { - if subschemas.is_array() { + if let Some(subschemas) = obj.get_mut("oneOf") + && subschemas.is_array() { let subschemas_clone = subschemas.clone(); obj.remove("oneOf"); obj.insert("anyOf".to_string(), subschemas_clone); } - } // Recursively process all nested objects and arrays for (_, value) in obj.iter_mut() { diff --git a/crates/assistant_tools/src/edit_agent.rs b/crates/assistant_tools/src/edit_agent.rs index aa321aa8f3..3fb75857c0 100644 --- a/crates/assistant_tools/src/edit_agent.rs +++ b/crates/assistant_tools/src/edit_agent.rs @@ -672,8 +672,8 @@ impl EditAgent { cx: &mut AsyncApp, ) -> Result>> { let mut messages_iter = conversation.messages.iter_mut(); - if let Some(last_message) = messages_iter.next_back() { - if last_message.role == Role::Assistant { + if let Some(last_message) = messages_iter.next_back() + && last_message.role == Role::Assistant { let old_content_len = last_message.content.len(); last_message .content @@ -685,18 +685,16 @@ impl EditAgent { // (e.g., the message will look very different on the next // request). Thus, we move the flag to the message prior to it, // as it will still be a valid prefix of the conversation. - if old_content_len != new_content_len && last_message.cache { - if let Some(prev_message) = messages_iter.next_back() { + if old_content_len != new_content_len && last_message.cache + && let Some(prev_message) = messages_iter.next_back() { last_message.cache = false; prev_message.cache = true; } - } if last_message.content.is_empty() { conversation.messages.pop(); } } - } conversation.messages.push(LanguageModelRequestMessage { role: Role::User, diff --git a/crates/assistant_tools/src/edit_agent/evals.rs b/crates/assistant_tools/src/edit_agent/evals.rs index 9a8e762455..5cf8c5df77 100644 --- a/crates/assistant_tools/src/edit_agent/evals.rs +++ b/crates/assistant_tools/src/edit_agent/evals.rs @@ -1283,15 +1283,14 @@ impl EvalAssertion { // Parse the score from the response let re = regex::Regex::new(r"(\d+)").unwrap(); - if let Some(captures) = re.captures(&output) { - if let Some(score_match) = captures.get(1) { + if let Some(captures) = re.captures(&output) + && let Some(score_match) = captures.get(1) { let score = score_match.as_str().parse().unwrap_or(0); return Ok(EvalAssertionOutcome { score, message: Some(output), }); } - } anyhow::bail!("No score found in response. Raw output: {output}"); }) diff --git a/crates/assistant_tools/src/edit_file_tool.rs b/crates/assistant_tools/src/edit_file_tool.rs index 039f9d9316..7538c5053f 100644 --- a/crates/assistant_tools/src/edit_file_tool.rs +++ b/crates/assistant_tools/src/edit_file_tool.rs @@ -155,11 +155,10 @@ impl Tool for EditFileTool { // It's also possible that the global config dir is configured to be inside the project, // so check for that edge case too. - if let Ok(canonical_path) = std::fs::canonicalize(&input.path) { - if canonical_path.starts_with(paths::config_dir()) { + if let Ok(canonical_path) = std::fs::canonicalize(&input.path) + && canonical_path.starts_with(paths::config_dir()) { return true; } - } // Check if path is inside the global config directory // First check if it's already inside project - if not, try to canonicalize @@ -199,11 +198,10 @@ impl Tool for EditFileTool { .any(|c| c.as_os_str() == local_settings_folder.as_os_str()) { description.push_str(" (local settings)"); - } else if let Ok(canonical_path) = std::fs::canonicalize(&input.path) { - if canonical_path.starts_with(paths::config_dir()) { + } else if let Ok(canonical_path) = std::fs::canonicalize(&input.path) + && canonical_path.starts_with(paths::config_dir()) { description.push_str(" (global settings)"); } - } description } diff --git a/crates/assistant_tools/src/grep_tool.rs b/crates/assistant_tools/src/grep_tool.rs index 1f00332c5a..1dd74b99e7 100644 --- a/crates/assistant_tools/src/grep_tool.rs +++ b/crates/assistant_tools/src/grep_tool.rs @@ -188,15 +188,14 @@ impl Tool for GrepTool { // Check if this file should be excluded based on its worktree settings if let Ok(Some(project_path)) = project.read_with(cx, |project, cx| { project.find_project_path(&path, cx) - }) { - if cx.update(|cx| { + }) + && cx.update(|cx| { let worktree_settings = WorktreeSettings::get(Some((&project_path).into()), cx); worktree_settings.is_path_excluded(&project_path.path) || worktree_settings.is_path_private(&project_path.path) }).unwrap_or(false) { continue; } - } while *parse_status.borrow() != ParseStatus::Idle { parse_status.changed().await?; @@ -284,12 +283,11 @@ impl Tool for GrepTool { output.extend(snapshot.text_for_range(range)); output.push_str("\n```\n"); - if let Some(ancestor_range) = ancestor_range { - if end_row < ancestor_range.end.row { + if let Some(ancestor_range) = ancestor_range + && end_row < ancestor_range.end.row { let remaining_lines = ancestor_range.end.row - end_row; writeln!(output, "\n{} lines remaining in ancestor node. Read the file to see all.", remaining_lines)?; } - } matches_found += 1; } diff --git a/crates/assistant_tools/src/schema.rs b/crates/assistant_tools/src/schema.rs index 10a8bf0acd..6aa4cdbf87 100644 --- a/crates/assistant_tools/src/schema.rs +++ b/crates/assistant_tools/src/schema.rs @@ -43,13 +43,11 @@ impl Transform for ToJsonSchemaSubsetTransform { fn transform(&mut self, schema: &mut Schema) { // Ensure that the type field is not an array, this happens when we use // Option, the type will be [T, "null"]. - if let Some(type_field) = schema.get_mut("type") { - if let Some(types) = type_field.as_array() { - if let Some(first_type) = types.first() { + if let Some(type_field) = schema.get_mut("type") + && let Some(types) = type_field.as_array() + && let Some(first_type) = types.first() { *type_field = first_type.clone(); } - } - } // oneOf is not supported, use anyOf instead if let Some(one_of) = schema.remove("oneOf") { diff --git a/crates/auto_update_helper/src/dialog.rs b/crates/auto_update_helper/src/dialog.rs index 757819df51..903ac34da2 100644 --- a/crates/auto_update_helper/src/dialog.rs +++ b/crates/auto_update_helper/src/dialog.rs @@ -186,11 +186,11 @@ unsafe extern "system" fn wnd_proc( }), WM_TERMINATE => { with_dialog_data(hwnd, |data| { - if let Ok(result) = data.borrow_mut().rx.recv() { - if let Err(e) = result { - log::error!("Failed to update Zed: {:?}", e); - show_error(format!("Error: {:?}", e)); - } + if let Ok(result) = data.borrow_mut().rx.recv() + && let Err(e) = result + { + log::error!("Failed to update Zed: {:?}", e); + show_error(format!("Error: {:?}", e)); } }); unsafe { PostQuitMessage(0) }; diff --git a/crates/breadcrumbs/src/breadcrumbs.rs b/crates/breadcrumbs/src/breadcrumbs.rs index 990fc27fbd..c9d67ea1e4 100644 --- a/crates/breadcrumbs/src/breadcrumbs.rs +++ b/crates/breadcrumbs/src/breadcrumbs.rs @@ -82,12 +82,11 @@ impl Render for Breadcrumbs { } text_style.color = Color::Muted.color(cx); - if index == 0 && !TabBarSettings::get_global(cx).show && active_item.is_dirty(cx) { - if let Some(styled_element) = apply_dirty_filename_style(&segment, &text_style, cx) + if index == 0 && !TabBarSettings::get_global(cx).show && active_item.is_dirty(cx) + && let Some(styled_element) = apply_dirty_filename_style(&segment, &text_style, cx) { return styled_element; } - } StyledText::new(segment.text.replace('\n', "⏎")) .with_default_highlights(&text_style, segment.highlights.unwrap_or_default()) diff --git a/crates/buffer_diff/src/buffer_diff.rs b/crates/buffer_diff/src/buffer_diff.rs index e20ea9713f..b88d492274 100644 --- a/crates/buffer_diff/src/buffer_diff.rs +++ b/crates/buffer_diff/src/buffer_diff.rs @@ -572,15 +572,14 @@ impl BufferDiffInner { pending_range.end.column = 0; } - if pending_range == (start_point..end_point) { - if !buffer.has_edits_since_in_range( + if pending_range == (start_point..end_point) + && !buffer.has_edits_since_in_range( &pending_hunk.buffer_version, start_anchor..end_anchor, ) { has_pending = true; secondary_status = pending_hunk.new_status; } - } } if let (Some(secondary_cursor), false) = (secondary_cursor.as_mut(), has_pending) { @@ -1036,8 +1035,8 @@ impl BufferDiff { _ => (true, Some(text::Anchor::MIN..text::Anchor::MAX)), }; - if let Some(secondary_changed_range) = secondary_diff_change { - if let Some(secondary_hunk_range) = + if let Some(secondary_changed_range) = secondary_diff_change + && let Some(secondary_hunk_range) = self.range_to_hunk_range(secondary_changed_range, buffer, cx) { if let Some(range) = &mut changed_range { @@ -1047,7 +1046,6 @@ impl BufferDiff { changed_range = Some(secondary_hunk_range); } } - } let state = &mut self.inner; state.base_text_exists = new_state.base_text_exists; diff --git a/crates/call/src/call_impl/room.rs b/crates/call/src/call_impl/room.rs index 73cb8518a6..b98510098e 100644 --- a/crates/call/src/call_impl/room.rs +++ b/crates/call/src/call_impl/room.rs @@ -827,8 +827,8 @@ impl Room { ); Audio::play_sound(Sound::Joined, cx); - if let Some(livekit_participants) = &livekit_participants { - if let Some(livekit_participant) = livekit_participants + if let Some(livekit_participants) = &livekit_participants + && let Some(livekit_participant) = livekit_participants .get(&ParticipantIdentity(user.id.to_string())) { for publication in @@ -847,7 +847,6 @@ impl Room { } } } - } } } @@ -940,11 +939,10 @@ impl Room { self.client.user_id() ) })?; - if self.live_kit.as_ref().map_or(true, |kit| kit.deafened) { - if publication.is_audio() { + if self.live_kit.as_ref().map_or(true, |kit| kit.deafened) + && publication.is_audio() { publication.set_enabled(false, cx); } - } match track { livekit_client::RemoteTrack::Audio(track) => { cx.emit(Event::RemoteAudioTracksChanged { @@ -1005,11 +1003,10 @@ impl Room { for (sid, participant) in &mut self.remote_participants { participant.speaking = speaker_ids.binary_search(sid).is_ok(); } - if let Some(id) = self.client.user_id() { - if let Some(room) = &mut self.live_kit { + if let Some(id) = self.client.user_id() + && let Some(room) = &mut self.live_kit { room.speaking = speaker_ids.binary_search(&id).is_ok(); } - } } RoomEvent::TrackMuted { @@ -1042,19 +1039,15 @@ impl Room { if let LocalTrack::Published { track_publication, .. } = &room.microphone_track - { - if track_publication.sid() == publication.sid() { + && track_publication.sid() == publication.sid() { room.microphone_track = LocalTrack::None; } - } if let LocalTrack::Published { track_publication, .. } = &room.screen_track - { - if track_publication.sid() == publication.sid() { + && track_publication.sid() == publication.sid() { room.screen_track = LocalTrack::None; } - } } } @@ -1484,11 +1477,10 @@ impl Room { self.set_deafened(deafened, cx); - if should_change_mute { - if let Some(task) = self.set_mute(deafened, cx) { + if should_change_mute + && let Some(task) = self.set_mute(deafened, cx) { task.detach_and_log_err(cx); } - } } } diff --git a/crates/channel/src/channel_buffer.rs b/crates/channel/src/channel_buffer.rs index 183f7eb3c6..5a6510913b 100644 --- a/crates/channel/src/channel_buffer.rs +++ b/crates/channel/src/channel_buffer.rs @@ -191,13 +191,11 @@ impl ChannelBuffer { operation, is_local: true, } => { - if *ZED_ALWAYS_ACTIVE { - if let language::Operation::UpdateSelections { selections, .. } = operation { - if selections.is_empty() { + if *ZED_ALWAYS_ACTIVE + && let language::Operation::UpdateSelections { selections, .. } = operation + && selections.is_empty() { return; } - } - } let operation = language::proto::serialize_operation(operation); self.client .send(proto::UpdateChannelBuffer { diff --git a/crates/channel/src/channel_chat.rs b/crates/channel/src/channel_chat.rs index 4ac37ffd14..fdf04d59d8 100644 --- a/crates/channel/src/channel_chat.rs +++ b/crates/channel/src/channel_chat.rs @@ -329,8 +329,8 @@ impl ChannelChat { loop { let step = chat .update(&mut cx, |chat, cx| { - if let Some(first_id) = chat.first_loaded_message_id() { - if first_id <= message_id { + if let Some(first_id) = chat.first_loaded_message_id() + && first_id <= message_id { let mut cursor = chat .messages .cursor::>(&()); @@ -347,7 +347,6 @@ impl ChannelChat { }, ); } - } ControlFlow::Continue(chat.load_more_messages(cx)) }) .log_err()?; @@ -359,8 +358,8 @@ impl ChannelChat { } pub fn acknowledge_last_message(&mut self, cx: &mut Context) { - if let ChannelMessageId::Saved(latest_message_id) = self.messages.summary().max_id { - if self + if let ChannelMessageId::Saved(latest_message_id) = self.messages.summary().max_id + && self .last_acknowledged_id .map_or(true, |acknowledged_id| acknowledged_id < latest_message_id) { @@ -375,7 +374,6 @@ impl ChannelChat { store.acknowledge_message_id(self.channel_id, latest_message_id, cx); }); } - } } async fn handle_loaded_messages( @@ -407,11 +405,10 @@ impl ChannelChat { let missing_ancestors = loaded_messages .iter() .filter_map(|message| { - if let Some(ancestor_id) = message.reply_to_message_id { - if !loaded_message_ids.contains(&ancestor_id) { + if let Some(ancestor_id) = message.reply_to_message_id + && !loaded_message_ids.contains(&ancestor_id) { return Some(ancestor_id); } - } None }) .collect::>(); @@ -646,8 +643,8 @@ impl ChannelChat { fn message_removed(&mut self, id: u64, cx: &mut Context) { let mut cursor = self.messages.cursor::(&()); let mut messages = cursor.slice(&ChannelMessageId::Saved(id), Bias::Left); - if let Some(item) = cursor.item() { - if item.id == ChannelMessageId::Saved(id) { + if let Some(item) = cursor.item() + && item.id == ChannelMessageId::Saved(id) { let deleted_message_ix = messages.summary().count; cursor.next(); messages.append(cursor.suffix(), &()); @@ -660,11 +657,10 @@ impl ChannelChat { let summary = self.messages.summary(); if summary.count == 0 { store.set_acknowledged_message_id(self.channel_id, None); - } else if deleted_message_ix == summary.count { - if let ChannelMessageId::Saved(id) = summary.max_id { + } else if deleted_message_ix == summary.count + && let ChannelMessageId::Saved(id) = summary.max_id { store.set_acknowledged_message_id(self.channel_id, Some(id)); } - } }); cx.emit(ChannelChatEvent::MessagesUpdated { @@ -672,7 +668,6 @@ impl ChannelChat { new_count: 0, }); } - } } fn message_update( diff --git a/crates/channel/src/channel_store.rs b/crates/channel/src/channel_store.rs index 4ad156b9fb..628a229fd7 100644 --- a/crates/channel/src/channel_store.rs +++ b/crates/channel/src/channel_store.rs @@ -262,13 +262,12 @@ impl ChannelStore { } } status = status_receiver.next().fuse() => { - if let Some(status) = status { - if status.is_connected() { + if let Some(status) = status + && status.is_connected() { this.update(cx, |this, _cx| { this.initialize(); }).ok(); } - } continue; } _ = timer => { @@ -336,11 +335,10 @@ impl ChannelStore { } pub fn has_open_channel_buffer(&self, channel_id: ChannelId, _cx: &App) -> bool { - if let Some(buffer) = self.opened_buffers.get(&channel_id) { - if let OpenEntityHandle::Open(buffer) = buffer { + if let Some(buffer) = self.opened_buffers.get(&channel_id) + && let OpenEntityHandle::Open(buffer) = buffer { return buffer.upgrade().is_some(); } - } false } @@ -408,14 +406,13 @@ impl ChannelStore { pub fn last_acknowledge_message_id(&self, channel_id: ChannelId) -> Option { self.channel_states.get(&channel_id).and_then(|state| { - if let Some(last_message_id) = state.latest_chat_message { - if state + if let Some(last_message_id) = state.latest_chat_message + && state .last_acknowledged_message_id() .is_some_and(|id| id < last_message_id) { return state.last_acknowledged_message_id(); } - } None }) @@ -962,19 +959,18 @@ impl ChannelStore { self.disconnect_channel_buffers_task.take(); for chat in self.opened_chats.values() { - if let OpenEntityHandle::Open(chat) = chat { - if let Some(chat) = chat.upgrade() { + if let OpenEntityHandle::Open(chat) = chat + && let Some(chat) = chat.upgrade() { chat.update(cx, |chat, cx| { chat.rejoin(cx); }); } - } } let mut buffer_versions = Vec::new(); for buffer in self.opened_buffers.values() { - if let OpenEntityHandle::Open(buffer) = buffer { - if let Some(buffer) = buffer.upgrade() { + if let OpenEntityHandle::Open(buffer) = buffer + && let Some(buffer) = buffer.upgrade() { let channel_buffer = buffer.read(cx); let buffer = channel_buffer.buffer().read(cx); buffer_versions.push(proto::ChannelBufferVersion { @@ -983,7 +979,6 @@ impl ChannelStore { version: language::proto::serialize_version(&buffer.version()), }); } - } } if buffer_versions.is_empty() { @@ -1078,11 +1073,10 @@ impl ChannelStore { if let Some(this) = this.upgrade() { this.update(cx, |this, cx| { for (_, buffer) in &this.opened_buffers { - if let OpenEntityHandle::Open(buffer) = &buffer { - if let Some(buffer) = buffer.upgrade() { + if let OpenEntityHandle::Open(buffer) = &buffer + && let Some(buffer) = buffer.upgrade() { buffer.update(cx, |buffer, cx| buffer.disconnect(cx)); } - } } }) .ok(); @@ -1157,11 +1151,9 @@ impl ChannelStore { } if let Some(OpenEntityHandle::Open(buffer)) = self.opened_buffers.remove(&channel_id) - { - if let Some(buffer) = buffer.upgrade() { + && let Some(buffer) = buffer.upgrade() { buffer.update(cx, ChannelBuffer::disconnect); } - } } } @@ -1170,13 +1162,11 @@ impl ChannelStore { let id = ChannelId(channel.id); let channel_changed = index.insert(channel); - if channel_changed { - if let Some(OpenEntityHandle::Open(buffer)) = self.opened_buffers.get(&id) { - if let Some(buffer) = buffer.upgrade() { + if channel_changed + && let Some(OpenEntityHandle::Open(buffer)) = self.opened_buffers.get(&id) + && let Some(buffer) = buffer.upgrade() { buffer.update(cx, ChannelBuffer::channel_changed); } - } - } } for latest_buffer_version in payload.latest_channel_buffer_versions { diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index a61d8e0911..d8b46dabb6 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -587,13 +587,10 @@ mod flatpak { pub fn set_bin_if_no_escape(mut args: super::Args) -> super::Args { if env::var(NO_ESCAPE_ENV_NAME).is_ok() && env::var("FLATPAK_ID").map_or(false, |id| id.starts_with("dev.zed.Zed")) + && args.zed.is_none() { - if args.zed.is_none() { - args.zed = Some("/app/libexec/zed-editor".into()); - unsafe { - env::set_var("ZED_UPDATE_EXPLANATION", "Please use flatpak to update zed") - }; - } + args.zed = Some("/app/libexec/zed-editor".into()); + unsafe { env::set_var("ZED_UPDATE_EXPLANATION", "Please use flatpak to update zed") }; } args } diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 66d5fd89b1..a68c0aeee2 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -864,14 +864,13 @@ impl Client { let mut credentials = None; let old_credentials = self.state.read().credentials.clone(); - if let Some(old_credentials) = old_credentials { - if self.validate_credentials(&old_credentials, cx).await? { + if let Some(old_credentials) = old_credentials + && self.validate_credentials(&old_credentials, cx).await? { credentials = Some(old_credentials); } - } - if credentials.is_none() && try_provider { - if let Some(stored_credentials) = self.credentials_provider.read_credentials(cx).await { + if credentials.is_none() && try_provider + && let Some(stored_credentials) = self.credentials_provider.read_credentials(cx).await { if self.validate_credentials(&stored_credentials, cx).await? { credentials = Some(stored_credentials); } else { @@ -881,7 +880,6 @@ impl Client { .log_err(); } } - } if credentials.is_none() { let mut status_rx = self.status(); diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs index da7f50076b..9f68cc84d3 100644 --- a/crates/client/src/user.rs +++ b/crates/client/src/user.rs @@ -894,11 +894,10 @@ impl UserStore { let mut ret = Vec::with_capacity(users.len()); for user in users { let user = User::new(user); - if let Some(old) = self.users.insert(user.id, user.clone()) { - if old.github_login != user.github_login { + if let Some(old) = self.users.insert(user.id, user.clone()) + && old.github_login != user.github_login { self.by_github_login.remove(&old.github_login); } - } self.by_github_login .insert(user.github_login.clone(), user.id); ret.push(user) diff --git a/crates/collab/src/api/events.rs b/crates/collab/src/api/events.rs index cd1dc42e64..fcc1669c1b 100644 --- a/crates/collab/src/api/events.rs +++ b/crates/collab/src/api/events.rs @@ -149,8 +149,8 @@ pub async fn post_crash( "crash report" ); - if let Some(kinesis_client) = app.kinesis_client.clone() { - if let Some(stream) = app.config.kinesis_stream.clone() { + if let Some(kinesis_client) = app.kinesis_client.clone() + && let Some(stream) = app.config.kinesis_stream.clone() { let properties = json!({ "app_version": report.header.app_version, "os_version": report.header.os_version, @@ -178,7 +178,6 @@ pub async fn post_crash( .await .log_err(); } - } if let Some(slack_panics_webhook) = app.config.slack_panics_webhook.clone() { let payload = slack::WebhookBody::new(|w| { @@ -359,8 +358,8 @@ pub async fn post_panic( "panic report" ); - if let Some(kinesis_client) = app.kinesis_client.clone() { - if let Some(stream) = app.config.kinesis_stream.clone() { + if let Some(kinesis_client) = app.kinesis_client.clone() + && let Some(stream) = app.config.kinesis_stream.clone() { let properties = json!({ "app_version": panic.app_version, "os_name": panic.os_name, @@ -387,7 +386,6 @@ pub async fn post_panic( .await .log_err(); } - } if !report_to_slack(&panic) { return Ok(()); @@ -518,8 +516,8 @@ pub async fn post_events( let first_event_at = chrono::Utc::now() - chrono::Duration::milliseconds(last_event.milliseconds_since_first_event); - if let Some(kinesis_client) = app.kinesis_client.clone() { - if let Some(stream) = app.config.kinesis_stream.clone() { + if let Some(kinesis_client) = app.kinesis_client.clone() + && let Some(stream) = app.config.kinesis_stream.clone() { let mut request = kinesis_client.put_records().stream_name(stream); let mut has_records = false; for row in for_snowflake( @@ -542,8 +540,7 @@ pub async fn post_events( if has_records { request.send().await.log_err(); } - } - }; + }; Ok(()) } diff --git a/crates/collab/src/api/extensions.rs b/crates/collab/src/api/extensions.rs index 9170c39e47..47c134d1d7 100644 --- a/crates/collab/src/api/extensions.rs +++ b/crates/collab/src/api/extensions.rs @@ -337,8 +337,7 @@ async fn fetch_extensions_from_blob_store( if known_versions .binary_search_by_key(&published_version, |known_version| known_version) .is_err() - { - if let Some(extension) = fetch_extension_manifest( + && let Some(extension) = fetch_extension_manifest( blob_store_client, blob_store_bucket, extension_id, @@ -352,7 +351,6 @@ async fn fetch_extensions_from_blob_store( .or_default() .push(extension); } - } } } diff --git a/crates/collab/src/auth.rs b/crates/collab/src/auth.rs index 00f37c6758..418a9b595b 100644 --- a/crates/collab/src/auth.rs +++ b/crates/collab/src/auth.rs @@ -79,8 +79,8 @@ pub async fn validate_header(mut req: Request, next: Next) -> impl Into verify_access_token(access_token, user_id, &state.db).await }; - if let Ok(validate_result) = validate_result { - if validate_result.is_valid { + if let Ok(validate_result) = validate_result + && validate_result.is_valid { let user = state .db .get_user_by_id(user_id) @@ -100,7 +100,6 @@ pub async fn validate_header(mut req: Request, next: Next) -> impl Into }; return Ok::<_, Error>(next.run(req).await); } - } Err(Error::http( StatusCode::UNAUTHORIZED, diff --git a/crates/collab/src/db/queries/extensions.rs b/crates/collab/src/db/queries/extensions.rs index 7d8aad2be4..6441edf1a6 100644 --- a/crates/collab/src/db/queries/extensions.rs +++ b/crates/collab/src/db/queries/extensions.rs @@ -87,11 +87,10 @@ impl Database { continue; }; - if let Some((_, max_extension_version)) = &max_versions.get(&version.extension_id) { - if max_extension_version > &extension_version { + if let Some((_, max_extension_version)) = &max_versions.get(&version.extension_id) + && max_extension_version > &extension_version { continue; } - } if let Some(constraints) = constraints { if !constraints @@ -331,11 +330,10 @@ impl Database { .exec_without_returning(&*tx) .await?; - if let Ok(db_version) = semver::Version::parse(&extension.latest_version) { - if db_version >= latest_version.version { + if let Ok(db_version) = semver::Version::parse(&extension.latest_version) + && db_version >= latest_version.version { continue; } - } let mut extension = extension.into_active_model(); extension.latest_version = ActiveValue::Set(latest_version.version.to_string()); diff --git a/crates/collab/src/db/queries/projects.rs b/crates/collab/src/db/queries/projects.rs index 9abab25ede..58405c81d0 100644 --- a/crates/collab/src/db/queries/projects.rs +++ b/crates/collab/src/db/queries/projects.rs @@ -1321,11 +1321,10 @@ impl Database { .await?; let mut connection_ids = HashSet::default(); - if let Some(host_connection) = project.host_connection().log_err() { - if !exclude_dev_server { + if let Some(host_connection) = project.host_connection().log_err() + && !exclude_dev_server { connection_ids.insert(host_connection); } - } while let Some(collaborator) = collaborators.next().await { let collaborator = collaborator?; diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index ef749ac9b7..41dad0f83d 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -616,11 +616,10 @@ impl Server { } } - if let Some(live_kit) = livekit_client.as_ref() { - if delete_livekit_room { + if let Some(live_kit) = livekit_client.as_ref() + && delete_livekit_room { live_kit.delete_room(livekit_room).await.trace_err(); } - } } } @@ -1015,8 +1014,8 @@ impl Server { inviter_id: UserId, invitee_id: UserId, ) -> Result<()> { - if let Some(user) = self.app_state.db.get_user_by_id(inviter_id).await? { - if let Some(code) = &user.invite_code { + if let Some(user) = self.app_state.db.get_user_by_id(inviter_id).await? + && let Some(code) = &user.invite_code { let pool = self.connection_pool.lock(); let invitee_contact = contact_for_user(invitee_id, false, &pool); for connection_id in pool.user_connection_ids(inviter_id) { @@ -1036,13 +1035,12 @@ impl Server { )?; } } - } Ok(()) } pub async fn invite_count_updated(self: &Arc, user_id: UserId) -> Result<()> { - if let Some(user) = self.app_state.db.get_user_by_id(user_id).await? { - if let Some(invite_code) = &user.invite_code { + if let Some(user) = self.app_state.db.get_user_by_id(user_id).await? + && let Some(invite_code) = &user.invite_code { let pool = self.connection_pool.lock(); for connection_id in pool.user_connection_ids(user_id) { self.peer.send( @@ -1057,7 +1055,6 @@ impl Server { )?; } } - } Ok(()) } @@ -1101,11 +1098,10 @@ fn broadcast( F: FnMut(ConnectionId) -> anyhow::Result<()>, { for receiver_id in receiver_ids { - if Some(receiver_id) != sender_id { - if let Err(error) = f(receiver_id) { + if Some(receiver_id) != sender_id + && let Err(error) = f(receiver_id) { tracing::error!("failed to send to {:?} {}", receiver_id, error); } - } } } @@ -2294,12 +2290,10 @@ async fn update_language_server( let db = session.db().await; if let Some(proto::update_language_server::Variant::MetadataUpdated(update)) = &request.variant - { - if let Some(capabilities) = update.capabilities.clone() { + && let Some(capabilities) = update.capabilities.clone() { db.update_server_capabilities(project_id, request.language_server_id, capabilities) .await?; } - } let project_connection_ids = db .project_connection_ids(project_id, session.connection_id, true) diff --git a/crates/collab/src/tests/random_project_collaboration_tests.rs b/crates/collab/src/tests/random_project_collaboration_tests.rs index 4d94d041b9..ca8a42d54d 100644 --- a/crates/collab/src/tests/random_project_collaboration_tests.rs +++ b/crates/collab/src/tests/random_project_collaboration_tests.rs @@ -1162,8 +1162,8 @@ impl RandomizedTest for ProjectCollaborationTest { Some((project, cx)) }); - if !guest_project.is_disconnected(cx) { - if let Some((host_project, host_cx)) = host_project { + if !guest_project.is_disconnected(cx) + && let Some((host_project, host_cx)) = host_project { let host_worktree_snapshots = host_project.read_with(host_cx, |host_project, cx| { host_project @@ -1235,7 +1235,6 @@ impl RandomizedTest for ProjectCollaborationTest { ); } } - } for buffer in guest_project.opened_buffers(cx) { let buffer = buffer.read(cx); diff --git a/crates/collab/src/tests/randomized_test_helpers.rs b/crates/collab/src/tests/randomized_test_helpers.rs index cabf10cfbc..bc3ca28da9 100644 --- a/crates/collab/src/tests/randomized_test_helpers.rs +++ b/crates/collab/src/tests/randomized_test_helpers.rs @@ -198,12 +198,11 @@ pub async fn run_randomized_test( } pub fn save_randomized_test_plan() { - if let Some(serialize_plan) = LAST_PLAN.lock().take() { - if let Some(path) = plan_save_path() { + if let Some(serialize_plan) = LAST_PLAN.lock().take() + && let Some(path) = plan_save_path() { eprintln!("saved test plan to path {:?}", path); std::fs::write(path, serialize_plan()).unwrap(); } - } } impl TestPlan { @@ -290,11 +289,9 @@ impl TestPlan { if let StoredOperation::Client { user_id, batch_id, .. } = operation - { - if batch_id == current_batch_id { + && batch_id == current_batch_id { return Some(user_id); } - } None })); user_ids.sort_unstable(); @@ -366,11 +363,9 @@ impl TestPlan { }, applied, ) = stored_operation - { - if user_id == ¤t_user_id { + && user_id == ¤t_user_id { return Some((operation.clone(), applied.clone())); } - } } None } else { @@ -550,12 +545,11 @@ impl TestPlan { .unwrap(); let pool = server.connection_pool.lock(); for contact in contacts { - if let db::Contact::Accepted { user_id, busy, .. } = contact { - if user_id == removed_user_id { + if let db::Contact::Accepted { user_id, busy, .. } = contact + && user_id == removed_user_id { assert!(!pool.is_user_online(user_id)); assert!(!busy); } - } } } diff --git a/crates/collab/src/user_backfiller.rs b/crates/collab/src/user_backfiller.rs index 71b99a3d4c..4e21e56eae 100644 --- a/crates/collab/src/user_backfiller.rs +++ b/crates/collab/src/user_backfiller.rs @@ -130,8 +130,8 @@ impl UserBackfiller { .and_then(|value| value.parse::().ok()) .and_then(|value| DateTime::from_timestamp(value, 0)); - if rate_limit_remaining == Some(0) { - if let Some(reset_at) = rate_limit_reset { + if rate_limit_remaining == Some(0) + && let Some(reset_at) = rate_limit_reset { let now = Utc::now(); if reset_at > now { let sleep_duration = reset_at - now; @@ -142,7 +142,6 @@ impl UserBackfiller { self.executor.sleep(sleep_duration.to_std().unwrap()).await; } } - } response .error_for_status() diff --git a/crates/collab_ui/src/channel_view.rs b/crates/collab_ui/src/channel_view.rs index b86d72d92f..919349fe4a 100644 --- a/crates/collab_ui/src/channel_view.rs +++ b/crates/collab_ui/src/channel_view.rs @@ -107,8 +107,8 @@ impl ChannelView { .find(|view| view.read(cx).channel_buffer.read(cx).remote_id(cx) == buffer_id); // If this channel buffer is already open in this pane, just return it. - if let Some(existing_view) = existing_view.clone() { - if existing_view.read(cx).channel_buffer == channel_view.read(cx).channel_buffer + if let Some(existing_view) = existing_view.clone() + && existing_view.read(cx).channel_buffer == channel_view.read(cx).channel_buffer { if let Some(link_position) = link_position { existing_view.update(cx, |channel_view, cx| { @@ -122,12 +122,11 @@ impl ChannelView { } return existing_view; } - } // If the pane contained a disconnected view for this channel buffer, // replace that. - if let Some(existing_item) = existing_view { - if let Some(ix) = pane.index_for_item(&existing_item) { + if let Some(existing_item) = existing_view + && let Some(ix) = pane.index_for_item(&existing_item) { pane.close_item_by_id( existing_item.entity_id(), SaveIntent::Skip, @@ -144,7 +143,6 @@ impl ChannelView { cx, ); } - } if let Some(link_position) = link_position { channel_view.update(cx, |channel_view, cx| { @@ -259,8 +257,8 @@ impl ChannelView { .editor .update(cx, |editor, cx| editor.snapshot(window, cx)); - if let Some(outline) = snapshot.buffer_snapshot.outline(None) { - if let Some(item) = outline + if let Some(outline) = snapshot.buffer_snapshot.outline(None) + && let Some(item) = outline .items .iter() .find(|item| &Channel::slug(&item.text).to_lowercase() == &position) @@ -279,7 +277,6 @@ impl ChannelView { }); return; } - } if !first_attempt { return; diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rs index 2bbaa8446c..b93c502a42 100644 --- a/crates/collab_ui/src/chat_panel.rs +++ b/crates/collab_ui/src/chat_panel.rs @@ -287,8 +287,8 @@ impl ChatPanel { } fn acknowledge_last_message(&mut self, cx: &mut Context) { - if self.active && self.is_scrolled_to_bottom { - if let Some((chat, _)) = &self.active_chat { + if self.active && self.is_scrolled_to_bottom + && let Some((chat, _)) = &self.active_chat { if let Some(channel_id) = self.channel_id(cx) { self.last_acknowledged_message_id = self .channel_store @@ -300,7 +300,6 @@ impl ChatPanel { chat.acknowledge_last_message(cx); }); } - } } fn render_replied_to_message( @@ -405,15 +404,14 @@ impl ChatPanel { && last_message.id != this_message.id && duration_since_last_message < Duration::from_secs(5 * 60); - if let ChannelMessageId::Saved(id) = this_message.id { - if this_message + if let ChannelMessageId::Saved(id) = this_message.id + && this_message .mentions .iter() .any(|(_, user_id)| Some(*user_id) == self.client.user_id()) { active_chat.acknowledge_message(id); } - } (this_message, is_continuation_from_previous, is_admin) }); @@ -871,8 +869,8 @@ impl ChatPanel { scroll_to_message_id.or(this.last_acknowledged_message_id) })?; - if let Some(message_id) = scroll_to_message_id { - if let Some(item_ix) = + if let Some(message_id) = scroll_to_message_id + && let Some(item_ix) = ChannelChat::load_history_since_message(chat.clone(), message_id, cx.clone()) .await { @@ -899,7 +897,6 @@ impl ChatPanel { } })?; } - } Ok(()) }) diff --git a/crates/collab_ui/src/chat_panel/message_editor.rs b/crates/collab_ui/src/chat_panel/message_editor.rs index 28d60d9221..11eb8da01a 100644 --- a/crates/collab_ui/src/chat_panel/message_editor.rs +++ b/crates/collab_ui/src/chat_panel/message_editor.rs @@ -241,8 +241,7 @@ impl MessageEditor { ) -> Task>> { if let Some((start_anchor, query, candidates)) = self.collect_mention_candidates(buffer, end_anchor, cx) - { - if !candidates.is_empty() { + && !candidates.is_empty() { return cx.spawn(async move |_, cx| { let completion_response = Self::completions_for_candidates( cx, @@ -255,12 +254,10 @@ impl MessageEditor { Ok(vec![completion_response]) }); } - } if let Some((start_anchor, query, candidates)) = self.collect_emoji_candidates(buffer, end_anchor, cx) - { - if !candidates.is_empty() { + && !candidates.is_empty() { return cx.spawn(async move |_, cx| { let completion_response = Self::completions_for_candidates( cx, @@ -273,7 +270,6 @@ impl MessageEditor { Ok(vec![completion_response]) }); } - } Task::ready(Ok(vec![CompletionResponse { completions: Vec::new(), @@ -474,8 +470,8 @@ impl MessageEditor { for range in ranges { text.clear(); text.extend(buffer.text_for_range(range.clone())); - if let Some(username) = text.strip_prefix('@') { - if let Some(user) = this + if let Some(username) = text.strip_prefix('@') + && let Some(user) = this .user_store .read(cx) .cached_user_by_github_login(username) @@ -486,7 +482,6 @@ impl MessageEditor { mentioned_user_ids.push(user.id); anchor_ranges.push(start..end); } - } } editor.clear_highlights::(cx); diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 8016481f6f..c8eb834827 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -311,11 +311,10 @@ impl CollabPanel { window, |this: &mut Self, _, event, window, cx| { if let editor::EditorEvent::Blurred = event { - if let Some(state) = &this.channel_editing_state { - if state.pending_name().is_some() { + if let Some(state) = &this.channel_editing_state + && state.pending_name().is_some() { return; } - } this.take_editing_state(window, cx); this.update_entries(false, cx); cx.notify(); @@ -491,12 +490,11 @@ impl CollabPanel { if !self.collapsed_sections.contains(&Section::ActiveCall) { let room = room.read(cx); - if query.is_empty() { - if let Some(channel_id) = room.channel_id() { + if query.is_empty() + && let Some(channel_id) = room.channel_id() { self.entries.push(ListEntry::ChannelNotes { channel_id }); self.entries.push(ListEntry::ChannelChat { channel_id }); } - } // Populate the active user. if let Some(user) = user_store.current_user() { @@ -639,11 +637,10 @@ impl CollabPanel { &Default::default(), executor.clone(), )); - if let Some(state) = &self.channel_editing_state { - if matches!(state, ChannelEditingState::Create { location: None, .. }) { + if let Some(state) = &self.channel_editing_state + && matches!(state, ChannelEditingState::Create { location: None, .. }) { self.entries.push(ListEntry::ChannelEditor { depth: 0 }); } - } let mut collapse_depth = None; for mat in matches { let channel = channel_store.channel_at_index(mat.candidate_id).unwrap(); @@ -1552,8 +1549,8 @@ impl CollabPanel { return; } - if let Some(selection) = self.selection { - if let Some(entry) = self.entries.get(selection) { + if let Some(selection) = self.selection + && let Some(entry) = self.entries.get(selection) { match entry { ListEntry::Header(section) => match section { Section::ActiveCall => Self::leave_call(window, cx), @@ -1645,7 +1642,6 @@ impl CollabPanel { ListEntry::ChannelEditor { .. } => {} } } - } } fn insert_space(&mut self, _: &InsertSpace, window: &mut Window, cx: &mut Context) { diff --git a/crates/collab_ui/src/notification_panel.rs b/crates/collab_ui/src/notification_panel.rs index 01ca533c10..855f26b5e8 100644 --- a/crates/collab_ui/src/notification_panel.rs +++ b/crates/collab_ui/src/notification_panel.rs @@ -121,14 +121,13 @@ impl NotificationPanel { let notification_list = ListState::new(0, ListAlignment::Top, px(1000.)); notification_list.set_scroll_handler(cx.listener( |this, event: &ListScrollEvent, _, cx| { - if event.count.saturating_sub(event.visible_range.end) < LOADING_THRESHOLD { - if let Some(task) = this + if event.count.saturating_sub(event.visible_range.end) < LOADING_THRESHOLD + && let Some(task) = this .notification_store .update(cx, |store, cx| store.load_more_notifications(false, cx)) { task.detach(); } - } }, )); @@ -469,8 +468,7 @@ impl NotificationPanel { channel_id, .. } = notification.clone() - { - if let Some(workspace) = self.workspace.upgrade() { + && let Some(workspace) = self.workspace.upgrade() { window.defer(cx, move |window, cx| { workspace.update(cx, |workspace, cx| { if let Some(panel) = workspace.focus_panel::(window, cx) { @@ -483,7 +481,6 @@ impl NotificationPanel { }); }); } - } } fn is_showing_notification(&self, notification: &Notification, cx: &mut Context) -> bool { @@ -491,8 +488,8 @@ impl NotificationPanel { return false; } - if let Notification::ChannelMessageMention { channel_id, .. } = ¬ification { - if let Some(workspace) = self.workspace.upgrade() { + if let Notification::ChannelMessageMention { channel_id, .. } = ¬ification + && let Some(workspace) = self.workspace.upgrade() { return if let Some(panel) = workspace.read(cx).panel::(cx) { let panel = panel.read(cx); panel.is_scrolled_to_bottom() @@ -503,7 +500,6 @@ impl NotificationPanel { false }; } - } false } @@ -582,8 +578,8 @@ impl NotificationPanel { } fn remove_toast(&mut self, notification_id: u64, cx: &mut Context) { - if let Some((current_id, _)) = &self.current_notification_toast { - if *current_id == notification_id { + if let Some((current_id, _)) = &self.current_notification_toast + && *current_id == notification_id { self.current_notification_toast.take(); self.workspace .update(cx, |workspace, cx| { @@ -592,7 +588,6 @@ impl NotificationPanel { }) .ok(); } - } } fn respond_to_notification( diff --git a/crates/context_server/src/client.rs b/crates/context_server/src/client.rs index 65283afa87..00ac1fb8d5 100644 --- a/crates/context_server/src/client.rs +++ b/crates/context_server/src/client.rs @@ -271,11 +271,10 @@ impl Client { ); } } else if let Ok(response) = serde_json::from_str::(&message) { - if let Some(handlers) = response_handlers.lock().as_mut() { - if let Some(handler) = handlers.remove(&response.id) { + if let Some(handlers) = response_handlers.lock().as_mut() + && let Some(handler) = handlers.remove(&response.id) { handler(Ok(message.to_string())); } - } } else if let Ok(notification) = serde_json::from_str::(&message) { let mut notification_handlers = notification_handlers.lock(); if let Some(handler) = notification_handlers.get_mut(notification.method.as_str()) { diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index dcebeae721..02c6ff55aa 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -608,8 +608,7 @@ impl Copilot { sign_in_status: status, .. }) = &mut this.server - { - if let SignInStatus::SigningIn { + && let SignInStatus::SigningIn { prompt: prompt_flow, .. } = status @@ -617,7 +616,6 @@ impl Copilot { *prompt_flow = Some(flow.clone()); cx.notify(); } - } })?; let response = lsp .request::( @@ -782,8 +780,8 @@ impl Copilot { event: &language::BufferEvent, cx: &mut Context, ) -> Result<()> { - if let Ok(server) = self.server.as_running() { - if let Some(registered_buffer) = server.registered_buffers.get_mut(&buffer.entity_id()) + if let Ok(server) = self.server.as_running() + && let Some(registered_buffer) = server.registered_buffers.get_mut(&buffer.entity_id()) { match event { language::BufferEvent::Edited => { @@ -836,14 +834,13 @@ impl Copilot { _ => {} } } - } Ok(()) } fn unregister_buffer(&mut self, buffer: &WeakEntity) { - if let Ok(server) = self.server.as_running() { - if let Some(buffer) = server.registered_buffers.remove(&buffer.entity_id()) { + if let Ok(server) = self.server.as_running() + && let Some(buffer) = server.registered_buffers.remove(&buffer.entity_id()) { server .lsp .notify::( @@ -853,7 +850,6 @@ impl Copilot { ) .ok(); } - } } pub fn completions( diff --git a/crates/dap_adapters/src/javascript.rs b/crates/dap_adapters/src/javascript.rs index 70b0638120..27f6022e1a 100644 --- a/crates/dap_adapters/src/javascript.rs +++ b/crates/dap_adapters/src/javascript.rs @@ -99,11 +99,10 @@ impl JsDebugAdapter { } } - if let Some(env) = configuration.get("env").cloned() { - if let Ok(env) = serde_json::from_value(env) { + if let Some(env) = configuration.get("env").cloned() + && let Ok(env) = serde_json::from_value(env) { envs = env; } - } configuration .entry("cwd") diff --git a/crates/debugger_tools/src/dap_log.rs b/crates/debugger_tools/src/dap_log.rs index 14154e5b39..6acf765d87 100644 --- a/crates/debugger_tools/src/dap_log.rs +++ b/crates/debugger_tools/src/dap_log.rs @@ -661,12 +661,11 @@ impl ToolbarItemView for DapLogToolbarItemView { _window: &mut Window, cx: &mut Context, ) -> workspace::ToolbarItemLocation { - if let Some(item) = active_pane_item { - if let Some(log_view) = item.downcast::() { + if let Some(item) = active_pane_item + && let Some(log_view) = item.downcast::() { self.log_view = Some(log_view.clone()); return workspace::ToolbarItemLocation::PrimaryLeft; } - } self.log_view = None; cx.notify(); diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index cf038871bc..9df6554dd7 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -530,11 +530,9 @@ impl DebugPanel { .active_session .as_ref() .map(|session| session.entity_id()) - { - if active_session_id == entity_id { + && active_session_id == entity_id { this.active_session = this.sessions_with_children.keys().next().cloned(); } - } cx.notify() }) .ok(); @@ -1302,11 +1300,10 @@ impl DebugPanel { cx: &mut Context<'_, Self>, ) -> Option { let adapter = parent_session.read(cx).adapter(); - if let Some(adapter) = DapRegistry::global(cx).adapter(&adapter) { - if let Some(label) = adapter.label_for_child_session(request) { + if let Some(adapter) = DapRegistry::global(cx).adapter(&adapter) + && let Some(label) = adapter.label_for_child_session(request) { return Some(label.into()); } - } None } diff --git a/crates/debugger_ui/src/new_process_modal.rs b/crates/debugger_ui/src/new_process_modal.rs index 51ea25a5cb..37d25db4ce 100644 --- a/crates/debugger_ui/src/new_process_modal.rs +++ b/crates/debugger_ui/src/new_process_modal.rs @@ -343,11 +343,10 @@ impl NewProcessModal { return; } - if let NewProcessMode::Launch = &self.mode { - if self.configure_mode.read(cx).save_to_debug_json.selected() { + if let NewProcessMode::Launch = &self.mode + && self.configure_mode.read(cx).save_to_debug_json.selected() { self.save_debug_scenario(window, cx); } - } let Some(debugger) = self.debugger.clone() else { return; diff --git a/crates/debugger_ui/src/session/running/breakpoint_list.rs b/crates/debugger_ui/src/session/running/breakpoint_list.rs index 9768f02e8e..aa08df71ab 100644 --- a/crates/debugger_ui/src/session/running/breakpoint_list.rs +++ b/crates/debugger_ui/src/session/running/breakpoint_list.rs @@ -239,12 +239,11 @@ impl BreakpointList { } fn select_next(&mut self, _: &menu::SelectNext, window: &mut Window, cx: &mut Context) { - if self.strip_mode.is_some() { - if self.input.focus_handle(cx).contains_focused(window, cx) { + if self.strip_mode.is_some() + && self.input.focus_handle(cx).contains_focused(window, cx) { cx.propagate(); return; } - } let ix = match self.selected_ix { _ if self.breakpoints.len() == 0 => None, None => Some(0), @@ -265,12 +264,11 @@ impl BreakpointList { window: &mut Window, cx: &mut Context, ) { - if self.strip_mode.is_some() { - if self.input.focus_handle(cx).contains_focused(window, cx) { + if self.strip_mode.is_some() + && self.input.focus_handle(cx).contains_focused(window, cx) { cx.propagate(); return; } - } let ix = match self.selected_ix { _ if self.breakpoints.len() == 0 => None, None => Some(self.breakpoints.len() - 1), @@ -286,12 +284,11 @@ impl BreakpointList { } fn select_first(&mut self, _: &menu::SelectFirst, window: &mut Window, cx: &mut Context) { - if self.strip_mode.is_some() { - if self.input.focus_handle(cx).contains_focused(window, cx) { + if self.strip_mode.is_some() + && self.input.focus_handle(cx).contains_focused(window, cx) { cx.propagate(); return; } - } let ix = if self.breakpoints.len() > 0 { Some(0) } else { @@ -301,12 +298,11 @@ impl BreakpointList { } fn select_last(&mut self, _: &menu::SelectLast, window: &mut Window, cx: &mut Context) { - if self.strip_mode.is_some() { - if self.input.focus_handle(cx).contains_focused(window, cx) { + if self.strip_mode.is_some() + && self.input.focus_handle(cx).contains_focused(window, cx) { cx.propagate(); return; } - } let ix = if self.breakpoints.len() > 0 { Some(self.breakpoints.len() - 1) } else { @@ -401,12 +397,11 @@ impl BreakpointList { let Some(entry) = self.selected_ix.and_then(|ix| self.breakpoints.get_mut(ix)) else { return; }; - if self.strip_mode.is_some() { - if self.input.focus_handle(cx).contains_focused(window, cx) { + if self.strip_mode.is_some() + && self.input.focus_handle(cx).contains_focused(window, cx) { cx.propagate(); return; } - } match &mut entry.kind { BreakpointEntryKind::LineBreakpoint(line_breakpoint) => { diff --git a/crates/debugger_ui/src/session/running/console.rs b/crates/debugger_ui/src/session/running/console.rs index 42989ddc20..74b44546d7 100644 --- a/crates/debugger_ui/src/session/running/console.rs +++ b/crates/debugger_ui/src/session/running/console.rs @@ -611,8 +611,8 @@ impl ConsoleQueryBarCompletionProvider { for variable in console.variable_list.update(cx, |variable_list, cx| { variable_list.completion_variables(cx) }) { - if let Some(evaluate_name) = &variable.evaluate_name { - if variables + if let Some(evaluate_name) = &variable.evaluate_name + && variables .insert(evaluate_name.clone(), variable.value.clone()) .is_none() { @@ -622,7 +622,6 @@ impl ConsoleQueryBarCompletionProvider { char_bag: evaluate_name.chars().collect(), }); } - } if variables .insert(variable.name.clone(), variable.value.clone()) diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 23dbf33322..766c50e50b 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -639,8 +639,8 @@ impl ProjectDiagnosticsEditor { #[cfg(test)] let cloned_blocks = blocks.clone(); - if was_empty { - if let Some(anchor_range) = anchor_ranges.first() { + if was_empty + && let Some(anchor_range) = anchor_ranges.first() { let range_to_select = anchor_range.start..anchor_range.start; this.editor.update(cx, |editor, cx| { editor.change_selections(Default::default(), window, cx, |s| { @@ -651,7 +651,6 @@ impl ProjectDiagnosticsEditor { this.editor.read(cx).focus_handle(cx).focus(window); } } - } let editor_blocks = anchor_ranges @@ -980,8 +979,7 @@ async fn heuristic_syntactic_expand( // Remove blank lines from start and end if let Some(start_row) = (outline_range.start.row..outline_range.end.row) .find(|row| !snapshot.line_indent_for_row(*row).is_line_blank()) - { - if let Some(end_row) = (outline_range.start.row..outline_range.end.row + 1) + && let Some(end_row) = (outline_range.start.row..outline_range.end.row + 1) .rev() .find(|row| !snapshot.line_indent_for_row(*row).is_line_blank()) { @@ -993,7 +991,6 @@ async fn heuristic_syntactic_expand( )); } } - } } let mut node = snapshot.syntax_ancestor(input_range.clone())?; diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index a16e516a70..5cdc7c15a4 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -969,15 +969,14 @@ impl DisplaySnapshot { if let Some(chunk_highlight) = chunk.highlight_style { // For color inlays, blend the color with the editor background let mut processed_highlight = chunk_highlight; - if chunk.is_inlay { - if let Some(inlay_color) = chunk_highlight.color { + if chunk.is_inlay + && let Some(inlay_color) = chunk_highlight.color { // Only blend if the color has transparency (alpha < 1.0) if inlay_color.a < 1.0 { let blended_color = editor_style.background.blend(inlay_color); processed_highlight.color = Some(blended_color); } } - } if let Some(highlight_style) = highlight_style.as_mut() { highlight_style.highlight(processed_highlight); @@ -2351,12 +2350,11 @@ pub mod tests { .highlight_style .and_then(|style| style.color) .map_or(black, |color| color.to_rgb()); - if let Some((last_chunk, last_severity, last_color)) = chunks.last_mut() { - if *last_severity == chunk.diagnostic_severity && *last_color == color { + if let Some((last_chunk, last_severity, last_color)) = chunks.last_mut() + && *last_severity == chunk.diagnostic_severity && *last_color == color { last_chunk.push_str(chunk.text); continue; } - } chunks.push((chunk.text.to_string(), chunk.diagnostic_severity, color)); } @@ -2901,12 +2899,11 @@ pub mod tests { .syntax_highlight_id .and_then(|id| id.style(theme)?.color); let highlight_color = chunk.highlight_style.and_then(|style| style.color); - if let Some((last_chunk, last_syntax_color, last_highlight_color)) = chunks.last_mut() { - if syntax_color == *last_syntax_color && highlight_color == *last_highlight_color { + if let Some((last_chunk, last_syntax_color, last_highlight_color)) = chunks.last_mut() + && syntax_color == *last_syntax_color && highlight_color == *last_highlight_color { last_chunk.push_str(chunk.text); continue; } - } chunks.push((chunk.text.to_string(), syntax_color, highlight_color)); } chunks diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index c4c9f2004a..e6cf62ab9f 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -525,8 +525,8 @@ impl BlockMap { // * Below blocks that end at the start of the edit // However, if we hit a replace block that ends at the start of the edit we want to reconstruct it. new_transforms.append(cursor.slice(&old_start, Bias::Left), &()); - if let Some(transform) = cursor.item() { - if transform.summary.input_rows > 0 + if let Some(transform) = cursor.item() + && transform.summary.input_rows > 0 && cursor.end() == old_start && transform .block @@ -547,7 +547,6 @@ impl BlockMap { } } } - } // Ensure the edit starts at a transform boundary. // If the edit starts within an isomorphic transform, preserve its prefix @@ -657,11 +656,10 @@ impl BlockMap { .iter() .filter_map(|block| { let placement = block.placement.to_wrap_row(wrap_snapshot)?; - if let BlockPlacement::Above(row) = placement { - if row < new_start { + if let BlockPlacement::Above(row) = placement + && row < new_start { return None; } - } Some((placement, Block::Custom(block.clone()))) }), ); @@ -977,11 +975,10 @@ impl BlockMapReader<'_> { break; } - if let Some(BlockId::Custom(id)) = transform.block.as_ref().map(|block| block.id()) { - if id == block_id { + if let Some(BlockId::Custom(id)) = transform.block.as_ref().map(|block| block.id()) + && id == block_id { return Some(cursor.start().1); } - } cursor.next(); } @@ -1299,15 +1296,14 @@ impl BlockSnapshot { let mut input_start = transform_input_start; let mut input_end = transform_input_start; - if let Some(transform) = cursor.item() { - if transform.block.is_none() { + if let Some(transform) = cursor.item() + && transform.block.is_none() { input_start += rows.start - transform_output_start; input_end += cmp::min( rows.end - transform_output_start, transform.summary.input_rows, ); } - } BlockChunks { input_chunks: self.wrap_snapshot.chunks( @@ -1472,8 +1468,8 @@ impl BlockSnapshot { longest_row_chars = summary.longest_row_chars; } - if let Some(transform) = cursor.item() { - if transform.block.is_none() { + if let Some(transform) = cursor.item() + && transform.block.is_none() { let Dimensions(output_start, input_start, _) = cursor.start(); let overshoot = range.end.0 - output_start.0; let wrap_start_row = input_start.0; @@ -1485,7 +1481,6 @@ impl BlockSnapshot { longest_row = BlockRow(output_start.0 + summary.longest_row); } } - } } longest_row @@ -1557,13 +1552,12 @@ impl BlockSnapshot { match transform.block.as_ref() { Some(block) => { - if block.is_replacement() { - if ((bias == Bias::Left || search_left) && output_start <= point.0) - || (!search_left && output_start >= point.0) + if block.is_replacement() + && (((bias == Bias::Left || search_left) && output_start <= point.0) + || (!search_left && output_start >= point.0)) { return BlockPoint(output_start); } - } } None => { let input_point = if point.row >= output_end_row.0 { @@ -3228,8 +3222,7 @@ mod tests { let mut is_in_replace_block = false; if let Some((BlockPlacement::Replace(replace_range), block)) = sorted_blocks_iter.peek() - { - if wrap_row >= replace_range.start().0 { + && wrap_row >= replace_range.start().0 { is_in_replace_block = true; if wrap_row == replace_range.start().0 { @@ -3257,7 +3250,6 @@ mod tests { sorted_blocks_iter.next(); } } - } if is_in_replace_block { expected_replaced_buffer_rows.insert(MultiBufferRow(multibuffer_row)); diff --git a/crates/editor/src/display_map/fold_map.rs b/crates/editor/src/display_map/fold_map.rs index c4e53a0f43..ffd1875174 100644 --- a/crates/editor/src/display_map/fold_map.rs +++ b/crates/editor/src/display_map/fold_map.rs @@ -289,8 +289,8 @@ impl FoldMapWriter<'_> { let ChunkRendererId::Fold(id) = id else { continue; }; - if let Some(metadata) = self.0.snapshot.fold_metadata_by_id.get(&id).cloned() { - if Some(new_width) != metadata.width { + if let Some(metadata) = self.0.snapshot.fold_metadata_by_id.get(&id).cloned() + && Some(new_width) != metadata.width { let buffer_start = metadata.range.start.to_offset(buffer); let buffer_end = metadata.range.end.to_offset(buffer); let inlay_range = inlay_snapshot.to_inlay_offset(buffer_start) @@ -308,7 +308,6 @@ impl FoldMapWriter<'_> { }, ); } - } } let edits = consolidate_inlay_edits(edits); @@ -417,8 +416,8 @@ impl FoldMap { cursor.seek(&InlayOffset(0), Bias::Right); while let Some(mut edit) = inlay_edits_iter.next() { - if let Some(item) = cursor.item() { - if !item.is_fold() { + if let Some(item) = cursor.item() + && !item.is_fold() { new_transforms.update_last( |transform| { if !transform.is_fold() { @@ -429,7 +428,6 @@ impl FoldMap { &(), ); } - } new_transforms.append(cursor.slice(&edit.old.start, Bias::Left), &()); edit.new.start -= edit.old.start - *cursor.start(); edit.old.start = *cursor.start(); diff --git a/crates/editor/src/display_map/inlay_map.rs b/crates/editor/src/display_map/inlay_map.rs index 76148af587..80fe4d2e4c 100644 --- a/crates/editor/src/display_map/inlay_map.rs +++ b/crates/editor/src/display_map/inlay_map.rs @@ -557,12 +557,11 @@ impl InlayMap { let mut buffer_edits_iter = buffer_edits.iter().peekable(); while let Some(buffer_edit) = buffer_edits_iter.next() { new_transforms.append(cursor.slice(&buffer_edit.old.start, Bias::Left), &()); - if let Some(Transform::Isomorphic(transform)) = cursor.item() { - if cursor.end().0 == buffer_edit.old.start { + if let Some(Transform::Isomorphic(transform)) = cursor.item() + && cursor.end().0 == buffer_edit.old.start { push_isomorphic(&mut new_transforms, *transform); cursor.next(); } - } // Remove all the inlays and transforms contained by the edit. let old_start = diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index 0d2d1c4a4c..7573ec435f 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -249,8 +249,8 @@ impl WrapMap { return; } - if let Some(wrap_width) = self.wrap_width { - if self.background_task.is_none() { + if let Some(wrap_width) = self.wrap_width + && self.background_task.is_none() { let pending_edits = self.pending_edits.clone(); let mut snapshot = self.snapshot.clone(); let text_system = cx.text_system().clone(); @@ -293,7 +293,6 @@ impl WrapMap { } } } - } let was_interpolated = self.snapshot.interpolated; let mut to_remove_len = 0; @@ -1065,13 +1064,12 @@ impl sum_tree::Item for Transform { } fn push_isomorphic(transforms: &mut Vec, summary: TextSummary) { - if let Some(last_transform) = transforms.last_mut() { - if last_transform.is_isomorphic() { + if let Some(last_transform) = transforms.last_mut() + && last_transform.is_isomorphic() { last_transform.summary.input += &summary; last_transform.summary.output += &summary; return; } - } transforms.push(Transform::isomorphic(summary)); } diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index c52a59a909..786e00030e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -942,11 +942,10 @@ impl ChangeList { } pub fn invert_last_group(&mut self) { - if let Some(last) = self.changes.last_mut() { - if let Some(current) = last.current.as_mut() { + if let Some(last) = self.changes.last_mut() + && let Some(current) = last.current.as_mut() { mem::swap(&mut last.original, current); } - } } } @@ -1861,8 +1860,8 @@ impl Editor { .then(|| language_settings::SoftWrap::None); let mut project_subscriptions = Vec::new(); - if full_mode { - if let Some(project) = project.as_ref() { + if full_mode + && let Some(project) = project.as_ref() { project_subscriptions.push(cx.subscribe_in( project, window, @@ -1969,7 +1968,6 @@ impl Editor { } })); } - } let buffer_snapshot = buffer.read(cx).snapshot(cx); @@ -2323,8 +2321,8 @@ impl Editor { editor.go_to_active_debug_line(window, cx); - if let Some(buffer) = buffer.read(cx).as_singleton() { - if let Some(project) = editor.project() { + if let Some(buffer) = buffer.read(cx).as_singleton() + && let Some(project) = editor.project() { let handle = project.update(cx, |project, cx| { project.register_buffer_with_language_servers(&buffer, cx) }); @@ -2332,7 +2330,6 @@ impl Editor { .registered_buffers .insert(buffer.read(cx).remote_id(), handle); } - } editor.minimap = editor.create_minimap(EditorSettings::get_global(cx).minimap, window, cx); @@ -3035,9 +3032,9 @@ impl Editor { } if local { - if let Some(buffer_id) = new_cursor_position.buffer_id { - if !self.registered_buffers.contains_key(&buffer_id) { - if let Some(project) = self.project.as_ref() { + if let Some(buffer_id) = new_cursor_position.buffer_id + && !self.registered_buffers.contains_key(&buffer_id) + && let Some(project) = self.project.as_ref() { project.update(cx, |project, cx| { let Some(buffer) = self.buffer.read(cx).buffer(buffer_id) else { return; @@ -3048,8 +3045,6 @@ impl Editor { ); }) } - } - } let mut context_menu = self.context_menu.borrow_mut(); let completion_menu = match context_menu.as_ref() { @@ -3063,8 +3058,8 @@ impl Editor { let completion_position = completion_menu.map(|menu| menu.initial_position); drop(context_menu); - if effects.completions { - if let Some(completion_position) = completion_position { + if effects.completions + && let Some(completion_position) = completion_position { let start_offset = selection_start.to_offset(buffer); let position_matches = start_offset == completion_position.to_offset(buffer); let continue_showing = if position_matches { @@ -3086,7 +3081,6 @@ impl Editor { self.hide_context_menu(window, cx); } } - } hide_hover(self, cx); @@ -3115,8 +3109,8 @@ impl Editor { if selections.len() == 1 { cx.emit(SearchEvent::ActiveMatchChanged) } - if local { - if let Some((_, _, buffer_snapshot)) = buffer.as_singleton() { + if local + && let Some((_, _, buffer_snapshot)) = buffer.as_singleton() { let inmemory_selections = selections .iter() .map(|s| { @@ -3130,8 +3124,7 @@ impl Editor { if WorkspaceSettings::get(None, cx).restore_on_startup != RestoreOnStartupBehavior::None - { - if let Some(workspace_id) = + && let Some(workspace_id) = self.workspace.as_ref().and_then(|workspace| workspace.1) { let snapshot = self.buffer().read(cx).snapshot(cx); @@ -3156,9 +3149,7 @@ impl Editor { .log_err(); }); } - } } - } cx.notify(); } @@ -4154,12 +4145,10 @@ impl Editor { if self.auto_replace_emoji_shortcode && selection.is_empty() && text.as_ref().ends_with(':') - { - if let Some(possible_emoji_short_code) = + && let Some(possible_emoji_short_code) = Self::find_possible_emoji_shortcode_at_position(&snapshot, selection.start) - { - if !possible_emoji_short_code.is_empty() { - if let Some(emoji) = emojis::get_by_shortcode(&possible_emoji_short_code) { + && !possible_emoji_short_code.is_empty() + && let Some(emoji) = emojis::get_by_shortcode(&possible_emoji_short_code) { let emoji_shortcode_start = Point::new( selection.start.row, selection.start.column - possible_emoji_short_code.len() as u32 - 1, @@ -4188,9 +4177,6 @@ impl Editor { continue; } - } - } - } // If not handling any auto-close operation, then just replace the selected // text with the given input and move the selection to the end of the @@ -4303,13 +4289,12 @@ impl Editor { |s| s.select(new_selections), ); - if !bracket_inserted { - if let Some(on_type_format_task) = + if !bracket_inserted + && let Some(on_type_format_task) = this.trigger_on_type_formatting(text.to_string(), window, cx) { on_type_format_task.detach_and_log_err(cx); } - } let editor_settings = EditorSettings::get_global(cx); if bracket_inserted @@ -5274,11 +5259,10 @@ impl Editor { } let language = buffer.language()?; - if let Some(restrict_to_languages) = restrict_to_languages { - if !restrict_to_languages.contains(language) { + if let Some(restrict_to_languages) = restrict_to_languages + && !restrict_to_languages.contains(language) { return None; } - } Some(( excerpt_id, ( @@ -5605,8 +5589,8 @@ impl Editor { // that having one source with `is_incomplete: true` doesn't cause all to be re-queried. let mut completions = Vec::new(); let mut is_incomplete = false; - if let Some(provider_responses) = provider_responses.await.log_err() { - if !provider_responses.is_empty() { + if let Some(provider_responses) = provider_responses.await.log_err() + && !provider_responses.is_empty() { for response in provider_responses { completions.extend(response.completions); is_incomplete = is_incomplete || response.is_incomplete; @@ -5615,7 +5599,6 @@ impl Editor { words = Task::ready(BTreeMap::default()); } } - } let mut words = words.await; if let Some(word_to_exclude) = &word_to_exclude { @@ -5718,8 +5701,8 @@ impl Editor { editor .update_in(cx, |editor, window, cx| { - if editor.focus_handle.is_focused(window) { - if let Some(menu) = menu { + if editor.focus_handle.is_focused(window) + && let Some(menu) = menu { *editor.context_menu.borrow_mut() = Some(CodeContextMenu::Completions(menu)); @@ -5733,7 +5716,6 @@ impl Editor { cx.notify(); return; } - } if editor.completion_tasks.len() <= 1 { // If there are no more completion tasks and the last menu was empty, we should hide it. @@ -6079,12 +6061,11 @@ impl Editor { Some(CodeActionSource::Indicator(_)) => Task::ready(Ok(Default::default())), _ => { let mut task_context_task = Task::ready(None); - if let Some(tasks) = &tasks { - if let Some(project) = project { + if let Some(tasks) = &tasks + && let Some(project) = project { task_context_task = Self::build_tasks_context(&project, &buffer, buffer_row, tasks, cx); } - } cx.spawn_in(window, { let buffer = buffer.clone(); @@ -6148,15 +6129,14 @@ impl Editor { deployed_from, })); cx.notify(); - if spawn_straight_away { - if let Some(task) = editor.confirm_code_action( + if spawn_straight_away + && let Some(task) = editor.confirm_code_action( &ConfirmCodeAction { item_ix: Some(0) }, window, cx, ) { return task; } - } Task::ready(Ok(())) }) @@ -6342,8 +6322,8 @@ impl Editor { .read(cx) .excerpt_containing(editor.selections.newest_anchor().head(), cx) })?; - if let Some((_, excerpted_buffer, excerpt_range)) = excerpt { - if excerpted_buffer == *buffer { + if let Some((_, excerpted_buffer, excerpt_range)) = excerpt + && excerpted_buffer == *buffer { let all_edits_within_excerpt = buffer.read_with(cx, |buffer, _| { let excerpt_range = excerpt_range.to_offset(buffer); buffer @@ -6358,7 +6338,6 @@ impl Editor { return Ok(()); } } - } } } else { return Ok(()); @@ -7779,11 +7758,10 @@ impl Editor { let indents = multibuffer.suggested_indents(cursor_point.row..cursor_point.row + 1, cx); - if let Some((_, indent)) = indents.iter().next() { - if indent.len == cursor_point.column { + if let Some((_, indent)) = indents.iter().next() + && indent.len == cursor_point.column { self.edit_prediction_indent_conflict = false; } - } } let edit_prediction = provider.suggest(&buffer, cursor_buffer_position, cx)?; @@ -9531,11 +9509,10 @@ impl Editor { let context_menu = self.context_menu.borrow_mut().take(); self.stale_edit_prediction_in_menu.take(); self.update_visible_edit_prediction(window, cx); - if let Some(CodeContextMenu::Completions(_)) = &context_menu { - if let Some(completion_provider) = &self.completion_provider { + if let Some(CodeContextMenu::Completions(_)) = &context_menu + && let Some(completion_provider) = &self.completion_provider { completion_provider.selection_changed(None, window, cx); } - } context_menu } @@ -9639,11 +9616,10 @@ impl Editor { s.select_ranges(tabstop.ranges.iter().rev().cloned()); }); - if let Some(choices) = &tabstop.choices { - if let Some(selection) = tabstop.ranges.first() { + if let Some(choices) = &tabstop.choices + && let Some(selection) = tabstop.ranges.first() { self.show_snippet_choices(choices, selection.clone(), cx) } - } // If we're already at the last tabstop and it's at the end of the snippet, // we're done, we don't need to keep the state around. @@ -9776,11 +9752,10 @@ impl Editor { s.select_ranges(current_ranges.iter().rev().cloned()) }); - if let Some(choices) = &snippet.choices[snippet.active_index] { - if let Some(selection) = current_ranges.first() { + if let Some(choices) = &snippet.choices[snippet.active_index] + && let Some(selection) = current_ranges.first() { self.show_snippet_choices(choices, selection.clone(), cx); } - } // If snippet state is not at the last tabstop, push it back on the stack if snippet.active_index + 1 < snippet.ranges.len() { @@ -10176,11 +10151,10 @@ impl Editor { // Avoid re-outdenting a row that has already been outdented by a // previous selection. - if let Some(last_row) = last_outdent { - if last_row == rows.start { + if let Some(last_row) = last_outdent + && last_row == rows.start { rows.start = rows.start.next_row(); } - } let has_multiple_rows = rows.len() > 1; for row in rows.iter_rows() { let indent_size = snapshot.indent_size_for_line(row); @@ -10357,12 +10331,11 @@ impl Editor { MultiBufferRow(selection.end.row) }; - if let Some(last_row_range) = row_ranges.last_mut() { - if start <= last_row_range.end { + if let Some(last_row_range) = row_ranges.last_mut() + && start <= last_row_range.end { last_row_range.end = end; continue; } - } row_ranges.push(start..end); } @@ -15331,9 +15304,9 @@ impl Editor { if direction == ExpandExcerptDirection::Down { let multi_buffer = self.buffer.read(cx); let snapshot = multi_buffer.snapshot(cx); - if let Some(buffer_id) = snapshot.buffer_id_for_excerpt(excerpt) { - if let Some(buffer) = multi_buffer.buffer(buffer_id) { - if let Some(excerpt_range) = snapshot.buffer_range_for_excerpt(excerpt) { + if let Some(buffer_id) = snapshot.buffer_id_for_excerpt(excerpt) + && let Some(buffer) = multi_buffer.buffer(buffer_id) + && let Some(excerpt_range) = snapshot.buffer_range_for_excerpt(excerpt) { let buffer_snapshot = buffer.read(cx).snapshot(); let excerpt_end_row = Point::from_anchor(&excerpt_range.end, &buffer_snapshot).row; @@ -15341,8 +15314,6 @@ impl Editor { let lines_below = last_row.saturating_sub(excerpt_end_row); should_scroll_up = lines_below >= lines_to_expand; } - } - } } self.buffer.update(cx, |buffer, cx| { @@ -15426,11 +15397,10 @@ impl Editor { let selection = self.selections.newest::(cx); let mut active_group_id = None; - if let ActiveDiagnostic::Group(active_group) = &self.active_diagnostics { - if active_group.active_range.start.to_offset(&buffer) == selection.start { + if let ActiveDiagnostic::Group(active_group) = &self.active_diagnostics + && active_group.active_range.start.to_offset(&buffer) == selection.start { active_group_id = Some(active_group.group_id); } - } fn filtered( snapshot: EditorSnapshot, @@ -16674,11 +16644,10 @@ impl Editor { buffer .update(cx, |buffer, cx| { - if let Some(transaction) = transaction { - if !buffer.is_singleton() { + if let Some(transaction) = transaction + && !buffer.is_singleton() { buffer.push_transaction(&transaction.0, cx); } - } cx.notify(); }) .ok(); @@ -16743,11 +16712,10 @@ impl Editor { buffer .update(cx, |buffer, cx| { // check if we need this - if let Some(transaction) = transaction { - if !buffer.is_singleton() { + if let Some(transaction) = transaction + && !buffer.is_singleton() { buffer.push_transaction(&transaction.0, cx); } - } cx.notify(); }) .ok(); @@ -17378,14 +17346,13 @@ impl Editor { } for row in (0..=range.start.row).rev() { - if let Some(crease) = display_map.crease_for_buffer_row(MultiBufferRow(row)) { - if crease.range().end.row >= buffer_start_row { + if let Some(crease) = display_map.crease_for_buffer_row(MultiBufferRow(row)) + && crease.range().end.row >= buffer_start_row { to_fold.push(crease); if row <= range.start.row { break; } } - } } } @@ -18693,11 +18660,10 @@ impl Editor { pub fn working_directory(&self, cx: &App) -> Option { if let Some(buffer) = self.buffer().read(cx).as_singleton() { - if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) { - if let Some(dir) = file.abs_path(cx).parent() { + if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) + && let Some(dir) = file.abs_path(cx).parent() { return Some(dir.to_owned()); } - } if let Some(project_path) = buffer.read(cx).project_path(cx) { return Some(project_path.path.to_path_buf()); @@ -18756,11 +18722,10 @@ impl Editor { _window: &mut Window, cx: &mut Context, ) { - if let Some(path) = self.target_file_abs_path(cx) { - if let Some(path) = path.to_str() { + if let Some(path) = self.target_file_abs_path(cx) + && let Some(path) = path.to_str() { cx.write_to_clipboard(ClipboardItem::new_string(path.to_string())); } - } } pub fn copy_relative_path( @@ -18769,11 +18734,10 @@ impl Editor { _window: &mut Window, cx: &mut Context, ) { - if let Some(path) = self.target_file_path(cx) { - if let Some(path) = path.to_str() { + if let Some(path) = self.target_file_path(cx) + && let Some(path) = path.to_str() { cx.write_to_clipboard(ClipboardItem::new_string(path.to_string())); } - } } pub fn project_path(&self, cx: &App) -> Option { @@ -18841,23 +18805,19 @@ impl Editor { _: &mut Window, cx: &mut Context, ) { - if let Some(file) = self.target_file(cx) { - if let Some(file_stem) = file.path().file_stem() { - if let Some(name) = file_stem.to_str() { + if let Some(file) = self.target_file(cx) + && let Some(file_stem) = file.path().file_stem() + && let Some(name) = file_stem.to_str() { cx.write_to_clipboard(ClipboardItem::new_string(name.to_string())); } - } - } } pub fn copy_file_name(&mut self, _: &CopyFileName, _: &mut Window, cx: &mut Context) { - if let Some(file) = self.target_file(cx) { - if let Some(file_name) = file.path().file_name() { - if let Some(name) = file_name.to_str() { + if let Some(file) = self.target_file(cx) + && let Some(file_name) = file.path().file_name() + && let Some(name) = file_name.to_str() { cx.write_to_clipboard(ClipboardItem::new_string(name.to_string())); } - } - } } pub fn toggle_git_blame( @@ -19126,11 +19086,10 @@ impl Editor { cx: &mut Context, ) { let selection = self.selections.newest::(cx).start.row + 1; - if let Some(file) = self.target_file(cx) { - if let Some(path) = file.path().to_str() { + if let Some(file) = self.target_file(cx) + && let Some(path) = file.path().to_str() { cx.write_to_clipboard(ClipboardItem::new_string(format!("{path}:{selection}"))); } - } } pub fn open_permalink_to_line( @@ -19769,11 +19728,10 @@ impl Editor { break; } let end = range.end.to_point(&display_snapshot.buffer_snapshot); - if let Some(current_row) = &end_row { - if end.row == current_row.row { + if let Some(current_row) = &end_row + && end.row == current_row.row { continue; } - } let start = range.start.to_point(&display_snapshot.buffer_snapshot); if start_row.is_none() { assert_eq!(end_row, None); @@ -20064,8 +20022,8 @@ impl Editor { if self.has_active_edit_prediction() { self.update_visible_edit_prediction(window, cx); } - if let Some(project) = self.project.as_ref() { - if let Some(edited_buffer) = edited_buffer { + if let Some(project) = self.project.as_ref() + && let Some(edited_buffer) = edited_buffer { project.update(cx, |project, cx| { self.registered_buffers .entry(edited_buffer.read(cx).remote_id()) @@ -20074,7 +20032,6 @@ impl Editor { }); }); } - } cx.emit(EditorEvent::BufferEdited); cx.emit(SearchEvent::MatchesInvalidated); @@ -20083,11 +20040,10 @@ impl Editor { } if *singleton_buffer_edited { - if let Some(buffer) = edited_buffer { - if buffer.read(cx).file().is_none() { + if let Some(buffer) = edited_buffer + && buffer.read(cx).file().is_none() { cx.emit(EditorEvent::TitleChanged); } - } if let Some(project) = &self.project { #[allow(clippy::mutable_key_type)] let languages_affected = multibuffer.update(cx, |multibuffer, cx| { @@ -20132,8 +20088,8 @@ impl Editor { } => { self.tasks_update_task = Some(self.refresh_runnables(window, cx)); let buffer_id = buffer.read(cx).remote_id(); - if self.buffer.read(cx).diff_for(buffer_id).is_none() { - if let Some(project) = &self.project { + if self.buffer.read(cx).diff_for(buffer_id).is_none() + && let Some(project) = &self.project { update_uncommitted_diff_for_buffer( cx.entity(), project, @@ -20143,7 +20099,6 @@ impl Editor { ) .detach(); } - } self.update_lsp_data(false, Some(buffer_id), window, cx); cx.emit(EditorEvent::ExcerptsAdded { buffer: buffer.clone(), @@ -20746,12 +20701,11 @@ impl Editor { let mut chunk_lines = chunk.text.split('\n').peekable(); while let Some(text) = chunk_lines.next() { let mut merged_with_last_token = false; - if let Some(last_token) = line.back_mut() { - if last_token.highlight == highlight { + if let Some(last_token) = line.back_mut() + && last_token.highlight == highlight { last_token.text.push_str(text); merged_with_last_token = true; } - } if !merged_with_last_token { line.push_back(Chunk { @@ -21209,8 +21163,8 @@ impl Editor { { let buffer_snapshot = OnceCell::new(); - if let Some(folds) = DB.get_editor_folds(item_id, workspace_id).log_err() { - if !folds.is_empty() { + if let Some(folds) = DB.get_editor_folds(item_id, workspace_id).log_err() + && !folds.is_empty() { let snapshot = buffer_snapshot.get_or_init(|| self.buffer.read(cx).snapshot(cx)); self.fold_ranges( @@ -21226,10 +21180,9 @@ impl Editor { cx, ); } - } - if let Some(selections) = DB.get_editor_selections(item_id, workspace_id).log_err() { - if !selections.is_empty() { + if let Some(selections) = DB.get_editor_selections(item_id, workspace_id).log_err() + && !selections.is_empty() { let snapshot = buffer_snapshot.get_or_init(|| self.buffer.read(cx).snapshot(cx)); // skip adding the initial selection to selection history @@ -21241,8 +21194,7 @@ impl Editor { })); }); self.selection_history.mode = SelectionHistoryMode::Normal; - } - }; + }; } self.read_scroll_position_from_db(item_id, workspace_id, window, cx); @@ -21283,18 +21235,15 @@ fn process_completion_for_edit( let mut snippet_source = completion.new_text.clone(); let mut previous_point = text::ToPoint::to_point(cursor_position, buffer); previous_point.column = previous_point.column.saturating_sub(1); - if let Some(scope) = buffer_snapshot.language_scope_at(previous_point) { - if scope.prefers_label_for_snippet_in_completion() { - if let Some(label) = completion.label() { - if matches!( + if let Some(scope) = buffer_snapshot.language_scope_at(previous_point) + && scope.prefers_label_for_snippet_in_completion() + && let Some(label) = completion.label() + && matches!( completion.kind(), Some(CompletionItemKind::FUNCTION) | Some(CompletionItemKind::METHOD) ) { snippet_source = label; } - } - } - } match Snippet::parse(&snippet_source).log_err() { Some(parsed_snippet) => (Some(parsed_snippet.clone()), parsed_snippet.text), None => (None, completion.new_text.clone()), @@ -21347,11 +21296,10 @@ fn process_completion_for_edit( ); let mut current_needle = text_to_replace.next(); for haystack_ch in completion.label.text.chars() { - if let Some(needle_ch) = current_needle { - if haystack_ch.eq_ignore_ascii_case(&needle_ch) { + if let Some(needle_ch) = current_needle + && haystack_ch.eq_ignore_ascii_case(&needle_ch) { current_needle = text_to_replace.next(); } - } } current_needle.is_none() } @@ -21604,12 +21552,11 @@ impl<'a> Iterator for WordBreakingTokenizer<'a> { offset += first_grapheme.len(); grapheme_len += 1; if is_grapheme_ideographic(first_grapheme) && !is_whitespace { - if let Some(grapheme) = iter.peek().copied() { - if should_stay_with_preceding_ideograph(grapheme) { + if let Some(grapheme) = iter.peek().copied() + && should_stay_with_preceding_ideograph(grapheme) { offset += grapheme.len(); grapheme_len += 1; } - } } else { let mut words = self.input[offset..].split_word_bound_indices().peekable(); let mut next_word_bound = words.peek().copied(); diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 927a207358..ccad266c96 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -916,8 +916,7 @@ impl EditorElement { cx.stop_propagation(); } else if cfg!(any(target_os = "linux", target_os = "freebsd")) && event.button == MouseButton::Middle - { - if !text_hitbox.is_hovered(window) || editor.read_only(cx) { + && (!text_hitbox.is_hovered(window) || editor.read_only(cx)) { return; } @@ -940,7 +939,6 @@ impl EditorElement { } cx.stop_propagation() } - } } fn click( @@ -1387,8 +1385,7 @@ impl EditorElement { ref drop_cursor, ref hide_drop_cursor, } = editor.selection_drag_state - { - if !hide_drop_cursor + && !hide_drop_cursor && (drop_cursor .start .cmp(&selection.start, &snapshot.buffer_snapshot) @@ -1410,7 +1407,6 @@ impl EditorElement { let absent_color = cx.theme().players().absent(); selections.push((absent_color, vec![drag_cursor_layout])); } - } } if let Some(collaboration_hub) = &editor.collaboration_hub { @@ -1420,20 +1416,16 @@ impl EditorElement { CollaboratorId::PeerId(peer_id) => { if let Some(collaborator) = collaboration_hub.collaborators(cx).get(&peer_id) - { - if let Some(participant_index) = collaboration_hub + && let Some(participant_index) = collaboration_hub .user_participant_indices(cx) .get(&collaborator.user_id) - { - if let Some((local_selection_style, _)) = selections.first_mut() + && let Some((local_selection_style, _)) = selections.first_mut() { *local_selection_style = cx .theme() .players() .color_for_participant(participant_index.0); } - } - } } CollaboratorId::Agent => { if let Some((local_selection_style, _)) = selections.first_mut() { @@ -3518,10 +3510,10 @@ impl EditorElement { let mut x_offset = px(0.); let mut is_block = true; - if let BlockId::Custom(custom_block_id) = block_id { - if block.has_height() { - if block.place_near() { - if let Some((x_target, line_width)) = x_position { + if let BlockId::Custom(custom_block_id) = block_id + && block.has_height() { + if block.place_near() + && let Some((x_target, line_width)) = x_position { let margin = em_width * 2; if line_width + final_size.width + margin < editor_width + editor_margins.gutter.full_width() @@ -3540,13 +3532,11 @@ impl EditorElement { .max(editor_margins.gutter.full_width()); x_offset = x_target.min(max_offset).max(min_offset); } - } - }; + }; if element_height_in_lines != block.height() { resized_blocks.insert(custom_block_id, element_height_in_lines); } } - } for i in 0..element_height_in_lines { row_block_types.insert(row + i, is_block); } @@ -3987,10 +3977,10 @@ impl EditorElement { } } - if let Some(focused_block) = focused_block { - if let Some(focus_handle) = focused_block.focus_handle.upgrade() { - if focus_handle.is_focused(window) { - if let Some(block) = snapshot.block_for_id(focused_block.id) { + if let Some(focused_block) = focused_block + && let Some(focus_handle) = focused_block.focus_handle.upgrade() + && focus_handle.is_focused(window) + && let Some(block) = snapshot.block_for_id(focused_block.id) { let style = block.style(); let width = match style { BlockStyle::Fixed => AvailableSpace::MinContent, @@ -4040,9 +4030,6 @@ impl EditorElement { }); } } - } - } - } if resized_blocks.is_empty() { *scroll_width = @@ -4203,8 +4190,8 @@ impl EditorElement { edit_prediction_popover_visible = true; } - if editor.context_menu_visible() { - if let Some(crate::ContextMenuOrigin::Cursor) = editor.context_menu_origin() { + if editor.context_menu_visible() + && let Some(crate::ContextMenuOrigin::Cursor) = editor.context_menu_origin() { let (min_height_in_lines, max_height_in_lines) = editor .context_menu_options .as_ref() @@ -4216,7 +4203,6 @@ impl EditorElement { max_menu_height += line_height * max_height_in_lines as f32 + POPOVER_Y_PADDING; context_menu_visible = true; } - } context_menu_placement = editor .context_menu_options .as_ref() @@ -5761,8 +5747,8 @@ impl EditorElement { cx: &mut App, ) { for (_, hunk_hitbox) in &layout.display_hunks { - if let Some(hunk_hitbox) = hunk_hitbox { - if !self + if let Some(hunk_hitbox) = hunk_hitbox + && !self .editor .read(cx) .buffer() @@ -5771,7 +5757,6 @@ impl EditorElement { { window.set_cursor_style(CursorStyle::PointingHand, hunk_hitbox); } - } } let show_git_gutter = layout @@ -10152,11 +10137,10 @@ fn compute_auto_height_layout( let overscroll = size(em_width, px(0.)); let editor_width = text_width - gutter_dimensions.margin - overscroll.width - em_width; - if !matches!(editor.soft_wrap_mode(cx), SoftWrap::None) { - if editor.set_wrap_width(Some(editor_width), cx) { + if !matches!(editor.soft_wrap_mode(cx), SoftWrap::None) + && editor.set_wrap_width(Some(editor_width), cx) { snapshot = editor.snapshot(window, cx); } - } let scroll_height = (snapshot.max_point().row().next_row().0 as f32) * line_height; diff --git a/crates/editor/src/git/blame.rs b/crates/editor/src/git/blame.rs index fc350a5a15..a0749ed30a 100644 --- a/crates/editor/src/git/blame.rs +++ b/crates/editor/src/git/blame.rs @@ -312,11 +312,10 @@ impl GitBlame { .as_ref() .and_then(|entry| entry.author.as_ref()) .map(|author| author.len()); - if let Some(author_len) = author_len { - if author_len > max_author_length { + if let Some(author_len) = author_len + && author_len > max_author_length { max_author_length = author_len; } - } } max_author_length @@ -416,8 +415,7 @@ impl GitBlame { if row_edits .peek() .map_or(true, |next_edit| next_edit.old.start >= old_end) - { - if let Some(entry) = cursor.item() { + && let Some(entry) = cursor.item() { if old_end > edit.old.end { new_entries.push( GitBlameEntry { @@ -430,7 +428,6 @@ impl GitBlame { cursor.next(); } - } } new_entries.append(cursor.suffix(), &()); drop(cursor); diff --git a/crates/editor/src/hover_links.rs b/crates/editor/src/hover_links.rs index 8b6e2cea84..2db1f58f1d 100644 --- a/crates/editor/src/hover_links.rs +++ b/crates/editor/src/hover_links.rs @@ -418,8 +418,7 @@ pub fn update_inlay_link_and_hover_points( } if let Some((language_server_id, location)) = hovered_hint_part.location - { - if secondary_held + && secondary_held && !editor.has_pending_nonempty_selection() { go_to_definition_updated = true; @@ -436,7 +435,6 @@ pub fn update_inlay_link_and_hover_points( cx, ); } - } } } }; @@ -766,11 +764,10 @@ pub(crate) fn find_url_from_range( let mut finder = LinkFinder::new(); finder.kinds(&[LinkKind::Url]); - if let Some(link) = finder.links(&text).next() { - if link.start() == 0 && link.end() == text.len() { + if let Some(link) = finder.links(&text).next() + && link.start() == 0 && link.end() == text.len() { return Some(link.as_str().to_string()); } - } None } diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index 6fe981fd6e..14198516b4 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -142,12 +142,11 @@ pub fn hover_at_inlay( .info_popovers .iter() .any(|InfoPopover { symbol_range, .. }| { - if let RangeInEditor::Inlay(range) = symbol_range { - if range == &inlay_hover.range { + if let RangeInEditor::Inlay(range) = symbol_range + && range == &inlay_hover.range { // Hover triggered from same location as last time. Don't show again. return true; } - } false }) { @@ -270,14 +269,13 @@ fn show_hover( } // Don't request again if the location is the same as the previous request - if let Some(triggered_from) = &editor.hover_state.triggered_from { - if triggered_from + if let Some(triggered_from) = &editor.hover_state.triggered_from + && triggered_from .cmp(&anchor, &snapshot.buffer_snapshot) .is_eq() { return None; } - } let hover_popover_delay = EditorSettings::get_global(cx).hover_popover_delay; let all_diagnostics_active = editor.active_diagnostics == ActiveDiagnostic::All; @@ -717,9 +715,9 @@ pub fn diagnostics_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { } pub fn open_markdown_url(link: SharedString, window: &mut Window, cx: &mut App) { - if let Ok(uri) = Url::parse(&link) { - if uri.scheme() == "file" { - if let Some(workspace) = window.root::().flatten() { + if let Ok(uri) = Url::parse(&link) + && uri.scheme() == "file" + && let Some(workspace) = window.root::().flatten() { workspace.update(cx, |workspace, cx| { let task = workspace.open_abs_path( PathBuf::from(uri.path()), @@ -769,8 +767,6 @@ pub fn open_markdown_url(link: SharedString, window: &mut Window, cx: &mut App) }); return; } - } - } cx.open_url(&link); } @@ -839,21 +835,19 @@ impl HoverState { pub fn focused(&self, window: &mut Window, cx: &mut Context) -> bool { let mut hover_popover_is_focused = false; for info_popover in &self.info_popovers { - if let Some(markdown_view) = &info_popover.parsed_content { - if markdown_view.focus_handle(cx).is_focused(window) { + if let Some(markdown_view) = &info_popover.parsed_content + && markdown_view.focus_handle(cx).is_focused(window) { hover_popover_is_focused = true; } - } } - if let Some(diagnostic_popover) = &self.diagnostic_popover { - if diagnostic_popover + if let Some(diagnostic_popover) = &self.diagnostic_popover + && diagnostic_popover .markdown .focus_handle(cx) .is_focused(window) { hover_popover_is_focused = true; } - } hover_popover_is_focused } } diff --git a/crates/editor/src/indent_guides.rs b/crates/editor/src/indent_guides.rs index f6d51c929a..e06b0c4ff2 100644 --- a/crates/editor/src/indent_guides.rs +++ b/crates/editor/src/indent_guides.rs @@ -168,12 +168,11 @@ pub fn indent_guides_in_range( while let Some(fold) = folds.next() { let start = fold.range.start.to_point(&snapshot.buffer_snapshot); let end = fold.range.end.to_point(&snapshot.buffer_snapshot); - if let Some(last_range) = fold_ranges.last_mut() { - if last_range.end >= start { + if let Some(last_range) = fold_ranges.last_mut() + && last_range.end >= start { last_range.end = last_range.end.max(end); continue; } - } fold_ranges.push(start..end); } diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rs index 60ad0e5bf6..573cfba864 100644 --- a/crates/editor/src/inlay_hint_cache.rs +++ b/crates/editor/src/inlay_hint_cache.rs @@ -498,8 +498,7 @@ impl InlayHintCache { cmp::Ordering::Less | cmp::Ordering::Equal => { if !old_kinds.contains(&cached_hint.kind) && new_kinds.contains(&cached_hint.kind) - { - if let Some(anchor) = multi_buffer_snapshot + && let Some(anchor) = multi_buffer_snapshot .anchor_in_excerpt(*excerpt_id, cached_hint.position) { to_insert.push(Inlay::hint( @@ -508,7 +507,6 @@ impl InlayHintCache { cached_hint, )); } - } excerpt_cache.next(); } cmp::Ordering::Greater => return true, @@ -522,8 +520,8 @@ impl InlayHintCache { for cached_hint_id in excerpt_cache { let maybe_missed_cached_hint = &excerpt_cached_hints.hints_by_id[cached_hint_id]; let cached_hint_kind = maybe_missed_cached_hint.kind; - if !old_kinds.contains(&cached_hint_kind) && new_kinds.contains(&cached_hint_kind) { - if let Some(anchor) = multi_buffer_snapshot + if !old_kinds.contains(&cached_hint_kind) && new_kinds.contains(&cached_hint_kind) + && let Some(anchor) = multi_buffer_snapshot .anchor_in_excerpt(*excerpt_id, maybe_missed_cached_hint.position) { to_insert.push(Inlay::hint( @@ -532,7 +530,6 @@ impl InlayHintCache { maybe_missed_cached_hint, )); } - } } } @@ -620,8 +617,8 @@ impl InlayHintCache { ) { if let Some(excerpt_hints) = self.hints.get(&excerpt_id) { let mut guard = excerpt_hints.write(); - if let Some(cached_hint) = guard.hints_by_id.get_mut(&id) { - if let ResolveState::CanResolve(server_id, _) = &cached_hint.resolve_state { + if let Some(cached_hint) = guard.hints_by_id.get_mut(&id) + && let ResolveState::CanResolve(server_id, _) = &cached_hint.resolve_state { let hint_to_resolve = cached_hint.clone(); let server_id = *server_id; cached_hint.resolve_state = ResolveState::Resolving; @@ -644,12 +641,11 @@ impl InlayHintCache { editor.inlay_hint_cache.hints.get(&excerpt_id) { let mut guard = excerpt_hints.write(); - if let Some(cached_hint) = guard.hints_by_id.get_mut(&id) { - if cached_hint.resolve_state == ResolveState::Resolving { + if let Some(cached_hint) = guard.hints_by_id.get_mut(&id) + && cached_hint.resolve_state == ResolveState::Resolving { resolved_hint.resolve_state = ResolveState::Resolved; *cached_hint = resolved_hint; } - } } })?; } @@ -658,7 +654,6 @@ impl InlayHintCache { }) .detach_and_log_err(cx); } - } } } } @@ -990,8 +985,8 @@ fn fetch_and_update_hints( let buffer = editor.buffer().read(cx).buffer(query.buffer_id)?; - if !editor.registered_buffers.contains_key(&query.buffer_id) { - if let Some(project) = editor.project.as_ref() { + if !editor.registered_buffers.contains_key(&query.buffer_id) + && let Some(project) = editor.project.as_ref() { project.update(cx, |project, cx| { editor.registered_buffers.insert( query.buffer_id, @@ -999,7 +994,6 @@ fn fetch_and_update_hints( ); }) } - } editor .semantics_provider @@ -1240,15 +1234,13 @@ fn apply_hint_update( .inlay_hint_cache .allowed_hint_kinds .contains(&new_hint.kind) - { - if let Some(new_hint_position) = + && let Some(new_hint_position) = multi_buffer_snapshot.anchor_in_excerpt(query.excerpt_id, new_hint.position) { splice .to_insert .push(Inlay::hint(new_inlay_id, new_hint_position, &new_hint)); } - } let new_id = InlayId::Hint(new_inlay_id); cached_excerpt_hints.hints_by_id.insert(new_id, new_hint); if cached_excerpt_hints.ordered_hints.len() <= insert_position { diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 22430ab5e1..39640ae5e9 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -930,11 +930,10 @@ impl Item for Editor { })?; buffer .update(cx, |buffer, cx| { - if let Some(transaction) = transaction { - if !buffer.is_singleton() { + if let Some(transaction) = transaction + && !buffer.is_singleton() { buffer.push_transaction(&transaction.0, cx); } - } }) .ok(); Ok(()) @@ -1374,9 +1373,8 @@ impl ProjectItem for Editor { let mut editor = Self::for_buffer(buffer.clone(), Some(project), window, cx); if let Some((excerpt_id, buffer_id, snapshot)) = editor.buffer().read(cx).snapshot(cx).as_singleton() - { - if WorkspaceSettings::get(None, cx).restore_on_file_reopen { - if let Some(restoration_data) = Self::project_item_kind() + && WorkspaceSettings::get(None, cx).restore_on_file_reopen + && let Some(restoration_data) = Self::project_item_kind() .and_then(|kind| pane.as_ref()?.project_item_restoration_data.get(&kind)) .and_then(|data| data.downcast_ref::()) .and_then(|data| { @@ -1403,8 +1401,6 @@ impl ProjectItem for Editor { ); editor.set_scroll_anchor(ScrollAnchor { anchor, offset }, window, cx); } - } - } editor } diff --git a/crates/editor/src/jsx_tag_auto_close.rs b/crates/editor/src/jsx_tag_auto_close.rs index f358ab7b93..dc41a9a467 100644 --- a/crates/editor/src/jsx_tag_auto_close.rs +++ b/crates/editor/src/jsx_tag_auto_close.rs @@ -51,13 +51,11 @@ pub(crate) fn should_auto_close( continue; }; let mut jsx_open_tag_node = node; - if node.grammar_name() != config.open_tag_node_name { - if let Some(parent) = node.parent() { - if parent.grammar_name() == config.open_tag_node_name { + if node.grammar_name() != config.open_tag_node_name + && let Some(parent) = node.parent() + && parent.grammar_name() == config.open_tag_node_name { jsx_open_tag_node = parent; } - } - } if jsx_open_tag_node.grammar_name() != config.open_tag_node_name { continue; } @@ -284,11 +282,10 @@ pub(crate) fn generate_auto_close_edits( unclosed_open_tag_count -= 1; } } else if has_erroneous_close_tag && kind == erroneous_close_tag_node_name { - if tag_node_name_equals(&node, &tag_name) { - if !is_after_open_tag(&node) { + if tag_node_name_equals(&node, &tag_name) + && !is_after_open_tag(&node) { unclosed_open_tag_count -= 1; } - } } else if kind == config.jsx_element_node_name { // perf: filter only open,close,element,erroneous nodes stack.extend(node.children(&mut cursor)); diff --git a/crates/editor/src/lsp_ext.rs b/crates/editor/src/lsp_ext.rs index d02fc0f901..ce35741388 100644 --- a/crates/editor/src/lsp_ext.rs +++ b/crates/editor/src/lsp_ext.rs @@ -147,8 +147,8 @@ pub fn lsp_tasks( }, cx, ) - }) { - if let Some(new_runnables) = runnables_task.await.log_err() { + }) + && let Some(new_runnables) = runnables_task.await.log_err() { new_lsp_tasks.extend(new_runnables.runnables.into_iter().filter_map( |(location, runnable)| { let resolved_task = @@ -157,7 +157,6 @@ pub fn lsp_tasks( }, )); } - } lsp_tasks .entry(source_kind) .or_insert_with(Vec::new) diff --git a/crates/editor/src/movement.rs b/crates/editor/src/movement.rs index 0bf875095b..99cdcd1b6e 100644 --- a/crates/editor/src/movement.rs +++ b/crates/editor/src/movement.rs @@ -510,11 +510,10 @@ pub fn find_preceding_boundary_point( if find_range == FindRange::SingleLine && ch == '\n' { break; } - if let Some(prev_ch) = prev_ch { - if is_boundary(ch, prev_ch) { + if let Some(prev_ch) = prev_ch + && is_boundary(ch, prev_ch) { break; } - } offset -= ch.len_utf8(); prev_ch = Some(ch); @@ -562,15 +561,14 @@ pub fn find_boundary_point( if find_range == FindRange::SingleLine && ch == '\n' { break; } - if let Some(prev_ch) = prev_ch { - if is_boundary(prev_ch, ch) { + if let Some(prev_ch) = prev_ch + && is_boundary(prev_ch, ch) { if return_point_before_boundary { return map.clip_point(prev_offset.to_display_point(map), Bias::Right); } else { break; } } - } prev_offset = offset; offset += ch.len_utf8(); prev_ch = Some(ch); @@ -603,15 +601,14 @@ pub fn find_preceding_boundary_trail( // Find the boundary let start_offset = offset; for ch in forward { - if let Some(prev_ch) = prev_ch { - if is_boundary(prev_ch, ch) { + if let Some(prev_ch) = prev_ch + && is_boundary(prev_ch, ch) { if start_offset == offset { trail_offset = Some(offset); } else { break; } } - } offset -= ch.len_utf8(); prev_ch = Some(ch); } @@ -651,15 +648,14 @@ pub fn find_boundary_trail( // Find the boundary let start_offset = offset; for ch in forward { - if let Some(prev_ch) = prev_ch { - if is_boundary(prev_ch, ch) { + if let Some(prev_ch) = prev_ch + && is_boundary(prev_ch, ch) { if start_offset == offset { trail_offset = Some(offset); } else { break; } } - } offset += ch.len_utf8(); prev_ch = Some(ch); } diff --git a/crates/editor/src/rust_analyzer_ext.rs b/crates/editor/src/rust_analyzer_ext.rs index bee9464124..94573a549d 100644 --- a/crates/editor/src/rust_analyzer_ext.rs +++ b/crates/editor/src/rust_analyzer_ext.rs @@ -285,12 +285,11 @@ pub fn open_docs(editor: &mut Editor, _: &OpenDocs, window: &mut Window, cx: &mu workspace.update(cx, |_workspace, cx| { // Check if the local document exists, otherwise fallback to the online document. // Open with the default browser. - if let Some(local_url) = docs_urls.local { - if fs::metadata(Path::new(&local_url[8..])).is_ok() { + if let Some(local_url) = docs_urls.local + && fs::metadata(Path::new(&local_url[8..])).is_ok() { cx.open_url(&local_url); return; } - } if let Some(web_url) = docs_urls.web { cx.open_url(&web_url); diff --git a/crates/editor/src/scroll.rs b/crates/editor/src/scroll.rs index 08ff23f8f7..f7b91cefd9 100644 --- a/crates/editor/src/scroll.rs +++ b/crates/editor/src/scroll.rs @@ -703,21 +703,19 @@ impl Editor { if matches!( settings.defaults.soft_wrap, SoftWrap::PreferredLineLength | SoftWrap::Bounded - ) { - if (settings.defaults.preferred_line_length as f32) < visible_column_count { + ) + && (settings.defaults.preferred_line_length as f32) < visible_column_count { visible_column_count = settings.defaults.preferred_line_length as f32; } - } // If the scroll position is currently at the left edge of the document // (x == 0.0) and the intent is to scroll right, the gutter's margin // should first be added to the current position, otherwise the cursor // will end at the column position minus the margin, which looks off. - if current_position.x == 0.0 && amount.columns(visible_column_count) > 0. { - if let Some(last_position_map) = &self.last_position_map { + if current_position.x == 0.0 && amount.columns(visible_column_count) > 0. + && let Some(last_position_map) = &self.last_position_map { current_position.x += self.gutter_dimensions.margin / last_position_map.em_advance; } - } let new_position = current_position + point( amount.columns(visible_column_count), @@ -749,13 +747,11 @@ impl Editor { if let (Some(visible_lines), Some(visible_columns)) = (self.visible_line_count(), self.visible_column_count()) - { - if newest_head.row() <= DisplayRow(screen_top.row().0 + visible_lines as u32) + && newest_head.row() <= DisplayRow(screen_top.row().0 + visible_lines as u32) && newest_head.column() <= screen_top.column() + visible_columns as u32 { return Ordering::Equal; } - } Ordering::Greater } diff --git a/crates/editor/src/scroll/autoscroll.rs b/crates/editor/src/scroll/autoscroll.rs index 88d3b52d76..2453ecad6d 100644 --- a/crates/editor/src/scroll/autoscroll.rs +++ b/crates/editor/src/scroll/autoscroll.rs @@ -116,14 +116,13 @@ impl Editor { let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx)); let mut scroll_position = self.scroll_manager.scroll_position(&display_map); let original_y = scroll_position.y; - if let Some(last_bounds) = self.expect_bounds_change.take() { - if scroll_position.y != 0. { + if let Some(last_bounds) = self.expect_bounds_change.take() + && scroll_position.y != 0. { scroll_position.y += (bounds.top() - last_bounds.top()) / line_height; if scroll_position.y < 0. { scroll_position.y = 0.; } } - } if scroll_position.y > max_scroll_top { scroll_position.y = max_scroll_top; } diff --git a/crates/editor/src/test.rs b/crates/editor/src/test.rs index 819d6d9fed..889cea8bc6 100644 --- a/crates/editor/src/test.rs +++ b/crates/editor/src/test.rs @@ -184,11 +184,10 @@ pub fn editor_content_with_blocks(editor: &Entity, cx: &mut VisualTestCo for (row, block) in blocks { match block { Block::Custom(custom_block) => { - if let BlockPlacement::Near(x) = &custom_block.placement { - if snapshot.intersects_fold(x.to_point(&snapshot.buffer_snapshot)) { + if let BlockPlacement::Near(x) = &custom_block.placement + && snapshot.intersects_fold(x.to_point(&snapshot.buffer_snapshot)) { continue; - } - }; + }; let content = block_content_for_tests(editor, custom_block.id, cx) .expect("block content not found"); // 2: "related info 1 for diagnostic 0" diff --git a/crates/eval/src/eval.rs b/crates/eval/src/eval.rs index 53c9113934..809b530ed7 100644 --- a/crates/eval/src/eval.rs +++ b/crates/eval/src/eval.rs @@ -167,15 +167,14 @@ fn main() { continue; } - if let Some(language) = meta.language_server { - if !languages.contains(&language.file_extension) { + if let Some(language) = meta.language_server + && !languages.contains(&language.file_extension) { panic!( "Eval for {:?} could not be run because no language server was found for extension {:?}", meta.name, language.file_extension ); } - } // TODO: This creates a worktree per repetition. Ideally these examples should // either be run sequentially on the same worktree, or reuse worktrees when there diff --git a/crates/eval/src/explorer.rs b/crates/eval/src/explorer.rs index ee1dfa95c3..778bad0706 100644 --- a/crates/eval/src/explorer.rs +++ b/crates/eval/src/explorer.rs @@ -46,28 +46,24 @@ fn find_target_files_recursive( max_depth, found_files, )?; - } else if path.is_file() { - if let Some(filename_osstr) = path.file_name() { - if let Some(filename_str) = filename_osstr.to_str() { - if filename_str == target_filename { + } else if path.is_file() + && let Some(filename_osstr) = path.file_name() + && let Some(filename_str) = filename_osstr.to_str() + && filename_str == target_filename { found_files.push(path); } - } - } - } } Ok(()) } pub fn generate_explorer_html(input_paths: &[PathBuf], output_path: &PathBuf) -> Result { - if let Some(parent) = output_path.parent() { - if !parent.exists() { + if let Some(parent) = output_path.parent() + && !parent.exists() { fs::create_dir_all(parent).context(format!( "Failed to create output directory: {}", parent.display() ))?; } - } let template_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/explorer.html"); let template_content = fs::read_to_string(&template_path).context(format!( diff --git a/crates/eval/src/instance.rs b/crates/eval/src/instance.rs index e3b67ed355..dd9b4f8bba 100644 --- a/crates/eval/src/instance.rs +++ b/crates/eval/src/instance.rs @@ -376,11 +376,10 @@ impl ExampleInstance { ); let result = this.thread.conversation(&mut example_cx).await; - if let Err(err) = result { - if !err.is::() { + if let Err(err) = result + && !err.is::() { return Err(err); } - } println!("{}Stopped", this.log_prefix); diff --git a/crates/extension/src/extension.rs b/crates/extension/src/extension.rs index 35f7f41938..40bd5b8ad4 100644 --- a/crates/extension/src/extension.rs +++ b/crates/extension/src/extension.rs @@ -178,8 +178,7 @@ pub fn parse_wasm_extension_version( for part in wasmparser::Parser::new(0).parse_all(wasm_bytes) { if let wasmparser::Payload::CustomSection(s) = part.context("error parsing wasm extension")? - { - if s.name() == "zed:api-version" { + && s.name() == "zed:api-version" { version = parse_wasm_extension_version_custom_section(s.data()); if version.is_none() { bail!( @@ -189,7 +188,6 @@ pub fn parse_wasm_extension_version( ); } } - } } // The reason we wait until we're done parsing all of the Wasm bytes to return the version diff --git a/crates/extension_host/src/extension_host.rs b/crates/extension_host/src/extension_host.rs index 4ee948dda8..2a0d29ba11 100644 --- a/crates/extension_host/src/extension_host.rs +++ b/crates/extension_host/src/extension_host.rs @@ -93,11 +93,9 @@ pub fn is_version_compatible( .wasm_api_version .as_ref() .and_then(|wasm_api_version| SemanticVersion::from_str(wasm_api_version).ok()) - { - if !is_supported_wasm_api_version(release_channel, wasm_api_version) { + && !is_supported_wasm_api_version(release_channel, wasm_api_version) { return false; } - } true } @@ -292,21 +290,18 @@ impl ExtensionStore { // it must be asynchronously rebuilt. let mut extension_index = ExtensionIndex::default(); let mut extension_index_needs_rebuild = true; - if let Ok(index_content) = index_content { - if let Some(index) = serde_json::from_str(&index_content).log_err() { + if let Ok(index_content) = index_content + && let Some(index) = serde_json::from_str(&index_content).log_err() { extension_index = index; if let (Ok(Some(index_metadata)), Ok(Some(extensions_metadata))) = (index_metadata, extensions_metadata) - { - if index_metadata + && index_metadata .mtime .bad_is_greater_than(extensions_metadata.mtime) { extension_index_needs_rebuild = false; } - } } - } // Immediately load all of the extensions in the initial manifest. If the // index needs to be rebuild, then enqueue @@ -392,11 +387,9 @@ impl ExtensionStore { if let Some(path::Component::Normal(extension_dir_name)) = event_path.components().next() - { - if let Some(extension_id) = extension_dir_name.to_str() { + && let Some(extension_id) = extension_dir_name.to_str() { reload_tx.unbounded_send(Some(extension_id.into())).ok(); } - } } } } @@ -763,8 +756,8 @@ impl ExtensionStore { if let ExtensionOperation::Install = operation { this.update( cx, |this, cx| { cx.emit(Event::ExtensionInstalled(extension_id.clone())); - if let Some(events) = ExtensionEvents::try_global(cx) { - if let Some(manifest) = this.extension_manifest_for_id(&extension_id) { + if let Some(events) = ExtensionEvents::try_global(cx) + && let Some(manifest) = this.extension_manifest_for_id(&extension_id) { events.update(cx, |this, cx| { this.emit( extension::Event::ExtensionInstalled(manifest.clone()), @@ -772,7 +765,6 @@ impl ExtensionStore { ) }); } - } }) .ok(); } @@ -912,13 +904,12 @@ impl ExtensionStore { extension_store.update(cx, |_, cx| { cx.emit(Event::ExtensionUninstalled(extension_id.clone())); - if let Some(events) = ExtensionEvents::try_global(cx) { - if let Some(manifest) = extension_manifest { + if let Some(events) = ExtensionEvents::try_global(cx) + && let Some(manifest) = extension_manifest { events.update(cx, |this, cx| { this.emit(extension::Event::ExtensionUninstalled(manifest.clone()), cx) }); } - } })?; anyhow::Ok(()) @@ -997,13 +988,12 @@ impl ExtensionStore { this.update(cx, |this, cx| this.reload(None, cx))?.await; this.update(cx, |this, cx| { cx.emit(Event::ExtensionInstalled(extension_id.clone())); - if let Some(events) = ExtensionEvents::try_global(cx) { - if let Some(manifest) = this.extension_manifest_for_id(&extension_id) { + if let Some(events) = ExtensionEvents::try_global(cx) + && let Some(manifest) = this.extension_manifest_for_id(&extension_id) { events.update(cx, |this, cx| { this.emit(extension::Event::ExtensionInstalled(manifest.clone()), cx) }); } - } })?; Ok(()) @@ -1788,11 +1778,10 @@ impl ExtensionStore { let connection_options = client.read(cx).connection_options(); let ssh_url = connection_options.ssh_url(); - if let Some(existing_client) = self.ssh_clients.get(&ssh_url) { - if existing_client.upgrade().is_some() { + if let Some(existing_client) = self.ssh_clients.get(&ssh_url) + && existing_client.upgrade().is_some() { return; } - } self.ssh_clients.insert(ssh_url, client.downgrade()); self.ssh_registered_tx.unbounded_send(()).ok(); diff --git a/crates/extension_host/src/wasm_host.rs b/crates/extension_host/src/wasm_host.rs index d990b670f4..d247b37eef 100644 --- a/crates/extension_host/src/wasm_host.rs +++ b/crates/extension_host/src/wasm_host.rs @@ -701,8 +701,7 @@ pub fn parse_wasm_extension_version( for part in wasmparser::Parser::new(0).parse_all(wasm_bytes) { if let wasmparser::Payload::CustomSection(s) = part.context("error parsing wasm extension")? - { - if s.name() == "zed:api-version" { + && s.name() == "zed:api-version" { version = parse_wasm_extension_version_custom_section(s.data()); if version.is_none() { bail!( @@ -712,7 +711,6 @@ pub fn parse_wasm_extension_version( ); } } - } } // The reason we wait until we're done parsing all of the Wasm bytes to return the version diff --git a/crates/extensions_ui/src/extensions_ui.rs b/crates/extensions_ui/src/extensions_ui.rs index 7c7f9e6836..34eedd94b1 100644 --- a/crates/extensions_ui/src/extensions_ui.rs +++ b/crates/extensions_ui/src/extensions_ui.rs @@ -1031,8 +1031,7 @@ impl ExtensionsPage { .read(cx) .extension_manifest_for_id(&extension_id) .cloned() - { - if let Some(events) = extension::ExtensionEvents::try_global(cx) { + && let Some(events) = extension::ExtensionEvents::try_global(cx) { events.update(cx, |this, cx| { this.emit( extension::Event::ConfigureExtensionRequested(manifest), @@ -1040,7 +1039,6 @@ impl ExtensionsPage { ) }); } - } } }) }), diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index e8f80e5ef2..d85756368f 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -209,12 +209,11 @@ impl FileFinder { let Some(init_modifiers) = self.init_modifiers.take() else { return; }; - if self.picker.read(cx).delegate.has_changed_selected_index { - if !event.modified() || !init_modifiers.is_subset_of(event) { + if self.picker.read(cx).delegate.has_changed_selected_index + && (!event.modified() || !init_modifiers.is_subset_of(event)) { self.init_modifiers = None; window.dispatch_action(menu::Confirm.boxed_clone(), cx); } - } } fn handle_select_prev( @@ -323,8 +322,8 @@ impl FileFinder { ) { self.picker.update(cx, |picker, cx| { let delegate = &mut picker.delegate; - if let Some(workspace) = delegate.workspace.upgrade() { - if let Some(m) = delegate.matches.get(delegate.selected_index()) { + if let Some(workspace) = delegate.workspace.upgrade() + && let Some(m) = delegate.matches.get(delegate.selected_index()) { let path = match &m { Match::History { path, .. } => { let worktree_id = path.project.worktree_id; @@ -344,7 +343,6 @@ impl FileFinder { }); open_task.detach_and_log_err(cx); } - } }) } @@ -675,8 +673,8 @@ impl Matches { let path_str = panel_match.0.path.to_string_lossy(); let filename_str = filename.to_string_lossy(); - if let Some(filename_pos) = path_str.rfind(&*filename_str) { - if panel_match.0.positions[0] >= filename_pos { + if let Some(filename_pos) = path_str.rfind(&*filename_str) + && panel_match.0.positions[0] >= filename_pos { let mut prev_position = panel_match.0.positions[0]; for p in &panel_match.0.positions[1..] { if *p != prev_position + 1 { @@ -686,7 +684,6 @@ impl Matches { } return true; } - } } false @@ -1045,11 +1042,10 @@ impl FileFinderDelegate { ) } else { let mut path = Arc::clone(project_relative_path); - if project_relative_path.as_ref() == Path::new("") { - if let Some(absolute_path) = &entry_path.absolute { + if project_relative_path.as_ref() == Path::new("") + && let Some(absolute_path) = &entry_path.absolute { path = Arc::from(absolute_path.as_path()); } - } let mut path_match = PathMatch { score: ix as f64, @@ -1078,11 +1074,11 @@ impl FileFinderDelegate { ), }; - if file_name_positions.is_empty() { - if let Some(user_home_path) = std::env::var("HOME").ok() { + if file_name_positions.is_empty() + && let Some(user_home_path) = std::env::var("HOME").ok() { let user_home_path = user_home_path.trim(); - if !user_home_path.is_empty() { - if full_path.starts_with(user_home_path) { + if !user_home_path.is_empty() + && full_path.starts_with(user_home_path) { full_path.replace_range(0..user_home_path.len(), "~"); full_path_positions.retain_mut(|pos| { if *pos >= user_home_path.len() { @@ -1094,9 +1090,7 @@ impl FileFinderDelegate { } }) } - } } - } if full_path.is_ascii() { let file_finder_settings = FileFinderSettings::get_global(cx); @@ -1242,16 +1236,14 @@ impl FileFinderDelegate { /// Skips first history match (that is displayed topmost) if it's currently opened. fn calculate_selected_index(&self, cx: &mut Context>) -> usize { - if FileFinderSettings::get_global(cx).skip_focus_for_active_in_search { - if let Some(Match::History { path, .. }) = self.matches.get(0) { - if Some(path) == self.currently_opened_path.as_ref() { + if FileFinderSettings::get_global(cx).skip_focus_for_active_in_search + && let Some(Match::History { path, .. }) = self.matches.get(0) + && Some(path) == self.currently_opened_path.as_ref() { let elements_after_first = self.matches.len() - 1; if elements_after_first > 0 { return 1; } } - } - } 0 } @@ -1310,11 +1302,10 @@ impl PickerDelegate for FileFinderDelegate { .enumerate() .find(|(_, m)| !matches!(m, Match::History { .. })) .map(|(i, _)| i); - if let Some(first_non_history_index) = first_non_history_index { - if first_non_history_index > 0 { + if let Some(first_non_history_index) = first_non_history_index + && first_non_history_index > 0 { return vec![first_non_history_index - 1]; } - } } Vec::new() } @@ -1436,8 +1427,8 @@ impl PickerDelegate for FileFinderDelegate { window: &mut Window, cx: &mut Context>, ) { - if let Some(m) = self.matches.get(self.selected_index()) { - if let Some(workspace) = self.workspace.upgrade() { + if let Some(m) = self.matches.get(self.selected_index()) + && let Some(workspace) = self.workspace.upgrade() { let open_task = workspace.update(cx, |workspace, cx| { let split_or_open = |workspace: &mut Workspace, @@ -1568,8 +1559,8 @@ impl PickerDelegate for FileFinderDelegate { cx.spawn_in(window, async move |_, cx| { let item = open_task.await.notify_async_err(cx)?; - if let Some(row) = row { - if let Some(active_editor) = item.downcast::() { + if let Some(row) = row + && let Some(active_editor) = item.downcast::() { active_editor .downgrade() .update_in(cx, |editor, window, cx| { @@ -1581,14 +1572,12 @@ impl PickerDelegate for FileFinderDelegate { }) .log_err(); } - } finder.update(cx, |_, cx| cx.emit(DismissEvent)).ok()?; Some(()) }) .detach(); } - } } fn dismissed(&mut self, _: &mut Window, cx: &mut Context>) { diff --git a/crates/file_finder/src/open_path_prompt.rs b/crates/file_finder/src/open_path_prompt.rs index 7235568e4f..4725ed6027 100644 --- a/crates/file_finder/src/open_path_prompt.rs +++ b/crates/file_finder/src/open_path_prompt.rs @@ -75,8 +75,8 @@ impl OpenPathDelegate { .. } => { let mut i = selected_match_index; - if let Some(user_input) = user_input { - if !user_input.exists || !user_input.is_dir { + if let Some(user_input) = user_input + && (!user_input.exists || !user_input.is_dir) { if i == 0 { return Some(CandidateInfo { path: user_input.file.clone(), @@ -86,7 +86,6 @@ impl OpenPathDelegate { i -= 1; } } - } let id = self.string_matches.get(i)?.candidate_id; entries.iter().find(|entry| entry.path.id == id).cloned() } diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 64eeae99d1..40f41551ad 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -420,18 +420,19 @@ impl Fs for RealFs { async fn remove_file(&self, path: &Path, options: RemoveOptions) -> Result<()> { #[cfg(windows)] - if let Ok(Some(metadata)) = self.metadata(path).await { - if metadata.is_symlink && metadata.is_dir { - self.remove_dir( - path, - RemoveOptions { - recursive: false, - ignore_if_not_exists: true, - }, - ) - .await?; - return Ok(()); - } + if let Ok(Some(metadata)) = self.metadata(path).await + && metadata.is_symlink + && metadata.is_dir + { + self.remove_dir( + path, + RemoveOptions { + recursive: false, + ignore_if_not_exists: true, + }, + ) + .await?; + return Ok(()); } match smol::fs::remove_file(path).await { @@ -467,11 +468,11 @@ impl Fs for RealFs { #[cfg(any(target_os = "linux", target_os = "freebsd"))] async fn trash_file(&self, path: &Path, _options: RemoveOptions) -> Result<()> { - if let Ok(Some(metadata)) = self.metadata(path).await { - if metadata.is_symlink { - // TODO: trash_file does not support trashing symlinks yet - https://github.com/bilelmoussaoui/ashpd/issues/255 - return self.remove_file(path, RemoveOptions::default()).await; - } + if let Ok(Some(metadata)) = self.metadata(path).await + && metadata.is_symlink + { + // TODO: trash_file does not support trashing symlinks yet - https://github.com/bilelmoussaoui/ashpd/issues/255 + return self.remove_file(path, RemoveOptions::default()).await; } let file = smol::fs::File::open(path).await?; match trash::trash_file(&file.as_fd()).await { @@ -766,24 +767,23 @@ impl Fs for RealFs { let pending_paths: Arc>> = Default::default(); let watcher = Arc::new(fs_watcher::FsWatcher::new(tx, pending_paths.clone())); - if watcher.add(path).is_err() { - // If the path doesn't exist yet (e.g. settings.json), watch the parent dir to learn when it's created. - if let Some(parent) = path.parent() { - if let Err(e) = watcher.add(parent) { - log::warn!("Failed to watch: {e}"); - } - } + // If the path doesn't exist yet (e.g. settings.json), watch the parent dir to learn when it's created. + if watcher.add(path).is_err() + && let Some(parent) = path.parent() + && let Err(e) = watcher.add(parent) + { + log::warn!("Failed to watch: {e}"); } // Check if path is a symlink and follow the target parent if let Some(mut target) = self.read_link(path).await.ok() { // Check if symlink target is relative path, if so make it absolute - if target.is_relative() { - if let Some(parent) = path.parent() { - target = parent.join(target); - if let Ok(canonical) = self.canonicalize(&target).await { - target = SanitizedPath::from(canonical).as_path().to_path_buf(); - } + if target.is_relative() + && let Some(parent) = path.parent() + { + target = parent.join(target); + if let Ok(canonical) = self.canonicalize(&target).await { + target = SanitizedPath::from(canonical).as_path().to_path_buf(); } } watcher.add(&target).ok(); @@ -1068,14 +1068,13 @@ impl FakeFsState { let current_entry = *entry_stack.last()?; if let FakeFsEntry::Dir { entries, .. } = current_entry { let entry = entries.get(name.to_str().unwrap())?; - if path_components.peek().is_some() || follow_symlink { - if let FakeFsEntry::Symlink { target, .. } = entry { + if (path_components.peek().is_some() || follow_symlink) + && let FakeFsEntry::Symlink { target, .. } = entry { let mut target = target.clone(); target.extend(path_components); path = target; continue 'outer; } - } entry_stack.push(entry); canonical_path = canonical_path.join(name); } else { @@ -1566,11 +1565,10 @@ impl FakeFs { pub fn insert_branches(&self, dot_git: &Path, branches: &[&str]) { self.with_git_state(dot_git, true, |state| { - if let Some(first) = branches.first() { - if state.current_branch_name.is_none() { + if let Some(first) = branches.first() + && state.current_branch_name.is_none() { state.current_branch_name = Some(first.to_string()) } - } state .branches .extend(branches.iter().map(ToString::to_string)); diff --git a/crates/fs/src/mac_watcher.rs b/crates/fs/src/mac_watcher.rs index aa75ad31d9..f46e049f96 100644 --- a/crates/fs/src/mac_watcher.rs +++ b/crates/fs/src/mac_watcher.rs @@ -41,11 +41,9 @@ impl Watcher for MacWatcher { if let Some((watched_path, _)) = handles .range::((Bound::Unbounded, Bound::Included(path))) .next_back() - { - if path.starts_with(watched_path) { + && path.starts_with(watched_path) { return Ok(()); } - } let (stream, handle) = EventStream::new(&[path], self.latency); let tx = self.events_tx.clone(); diff --git a/crates/fsevent/src/fsevent.rs b/crates/fsevent/src/fsevent.rs index 81ca0a4114..96516e13c0 100644 --- a/crates/fsevent/src/fsevent.rs +++ b/crates/fsevent/src/fsevent.rs @@ -178,8 +178,7 @@ impl EventStream { flags.contains(StreamFlags::USER_DROPPED) || flags.contains(StreamFlags::KERNEL_DROPPED) }) - { - if let Some(last_valid_event_id) = state.last_valid_event_id.take() { + && let Some(last_valid_event_id) = state.last_valid_event_id.take() { fs::FSEventStreamStop(state.stream); fs::FSEventStreamInvalidate(state.stream); fs::FSEventStreamRelease(state.stream); @@ -212,7 +211,6 @@ impl EventStream { fs::FSEventStreamStart(state.stream); stream_restarted = true; } - } if !stream_restarted { let mut events = Vec::with_capacity(num); diff --git a/crates/git/src/blame.rs b/crates/git/src/blame.rs index 6f12681ea0..46f8c94f39 100644 --- a/crates/git/src/blame.rs +++ b/crates/git/src/blame.rs @@ -289,8 +289,8 @@ fn parse_git_blame(output: &str) -> Result> { } }; - if done { - if let Some(entry) = current_entry.take() { + if done + && let Some(entry) = current_entry.take() { index.insert(entry.sha, entries.len()); // We only want annotations that have a commit. @@ -298,7 +298,6 @@ fn parse_git_blame(output: &str) -> Result> { entries.push(entry); } } - } } Ok(entries) diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index ae8c5f849c..71e5a56927 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -1447,13 +1447,11 @@ impl GitRepository for RealGitRepository { let mut remote_branches = vec![]; let mut add_if_matching = async |remote_head: &str| { - if let Ok(merge_base) = git_cmd(&["merge-base", &head, remote_head]).await { - if merge_base.trim() == head { - if let Some(s) = remote_head.strip_prefix("refs/remotes/") { + if let Ok(merge_base) = git_cmd(&["merge-base", &head, remote_head]).await + && merge_base.trim() == head + && let Some(s) = remote_head.strip_prefix("refs/remotes/") { remote_branches.push(s.to_owned().into()); } - } - } }; // check the main branch of each remote @@ -1574,11 +1572,9 @@ impl GitRepository for RealGitRepository { Err(error) => { if let Some(GitBinaryCommandError { status, .. }) = error.downcast_ref::() - { - if status.code() == Some(1) { + && status.code() == Some(1) { return Ok(false); } - } Err(error) } diff --git a/crates/git_hosting_providers/src/git_hosting_providers.rs b/crates/git_hosting_providers/src/git_hosting_providers.rs index d4b3a59375..87766966bc 100644 --- a/crates/git_hosting_providers/src/git_hosting_providers.rs +++ b/crates/git_hosting_providers/src/git_hosting_providers.rs @@ -49,11 +49,10 @@ pub fn register_additional_providers( pub fn get_host_from_git_remote_url(remote_url: &str) -> Result { maybe!({ - if let Some(remote_url) = remote_url.strip_prefix("git@") { - if let Some((host, _)) = remote_url.trim_start_matches("git@").split_once(':') { + if let Some(remote_url) = remote_url.strip_prefix("git@") + && let Some((host, _)) = remote_url.trim_start_matches("git@").split_once(':') { return Some(host.to_string()); } - } Url::parse(remote_url) .ok() diff --git a/crates/git_ui/src/commit_modal.rs b/crates/git_ui/src/commit_modal.rs index 5e7430ebc6..c0d97ebbc7 100644 --- a/crates/git_ui/src/commit_modal.rs +++ b/crates/git_ui/src/commit_modal.rs @@ -135,12 +135,10 @@ impl CommitModal { .as_ref() .and_then(|repo| repo.read(cx).head_commit.as_ref()) .is_some() - { - if !git_panel.amend_pending() { + && !git_panel.amend_pending() { git_panel.set_amend_pending(true, cx); git_panel.load_last_commit_message_if_empty(cx); } - } } ForceMode::Commit => { if git_panel.amend_pending() { @@ -195,13 +193,12 @@ impl CommitModal { let commit_message = commit_editor.read(cx).text(cx); - if let Some(suggested_commit_message) = suggested_commit_message { - if commit_message.is_empty() { + if let Some(suggested_commit_message) = suggested_commit_message + && commit_message.is_empty() { commit_editor.update(cx, |editor, cx| { editor.set_placeholder_text(suggested_commit_message, cx); }); } - } let focus_handle = commit_editor.focus_handle(cx); diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index b1bdcdc3e0..4c31854428 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -926,9 +926,9 @@ impl GitPanel { let workspace = self.workspace.upgrade()?; let git_repo = self.active_repository.as_ref()?; - if let Some(project_diff) = workspace.read(cx).active_item_as::(cx) { - if let Some(project_path) = project_diff.read(cx).active_path(cx) { - if Some(&entry.repo_path) + if let Some(project_diff) = workspace.read(cx).active_item_as::(cx) + && let Some(project_path) = project_diff.read(cx).active_path(cx) + && Some(&entry.repo_path) == git_repo .read(cx) .project_path_to_repo_path(&project_path, cx) @@ -937,9 +937,7 @@ impl GitPanel { project_diff.focus_handle(cx).focus(window); project_diff.update(cx, |project_diff, cx| project_diff.autoscroll(cx)); return None; - } - } - }; + }; self.workspace .update(cx, |workspace, cx| { @@ -2514,11 +2512,10 @@ impl GitPanel { new_co_authors.push((name.clone(), email.clone())) } } - if !project.is_local() && !project.is_read_only(cx) { - if let Some(local_committer) = self.local_committer(room, cx) { + if !project.is_local() && !project.is_read_only(cx) + && let Some(local_committer) = self.local_committer(room, cx) { new_co_authors.push(local_committer); } - } new_co_authors } @@ -2758,15 +2755,14 @@ impl GitPanel { pending_staged_count += pending.entries.len(); last_pending_staged = pending.entries.first().cloned(); } - if let Some(single_staged) = &single_staged_entry { - if pending + if let Some(single_staged) = &single_staged_entry + && pending .entries .iter() .any(|entry| entry.repo_path == single_staged.repo_path) { pending_status_for_single_staged = Some(pending.target_status); } - } } if conflict_entries.len() == 0 && staged_count == 1 && pending_staged_count == 0 { diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index 09c5ce1152..d448c6ef41 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/crates/git_ui/src/project_diff.rs @@ -363,11 +363,10 @@ impl ProjectDiff { } _ => {} } - if editor.focus_handle(cx).contains_focused(window, cx) { - if self.multibuffer.read(cx).is_empty() { + if editor.focus_handle(cx).contains_focused(window, cx) + && self.multibuffer.read(cx).is_empty() { self.focus_handle.focus(window) } - } } fn load_buffers(&mut self, cx: &mut Context) -> Vec>> { diff --git a/crates/go_to_line/src/cursor_position.rs b/crates/go_to_line/src/cursor_position.rs index af92621378..161c7938c4 100644 --- a/crates/go_to_line/src/cursor_position.rs +++ b/crates/go_to_line/src/cursor_position.rs @@ -95,11 +95,10 @@ impl CursorPosition { .ok() .unwrap_or(true); - if !is_singleton { - if let Some(debounce) = debounce { + if !is_singleton + && let Some(debounce) = debounce { cx.background_executor().timer(debounce).await; } - } editor .update(cx, |editor, cx| { @@ -234,14 +233,12 @@ impl Render for CursorPosition { if let Some(editor) = workspace .active_item(cx) .and_then(|item| item.act_as::(cx)) - { - if let Some((_, buffer, _)) = editor.read(cx).active_excerpt(cx) + && let Some((_, buffer, _)) = editor.read(cx).active_excerpt(cx) { workspace.toggle_modal(window, cx, |window, cx| { crate::GoToLine::new(editor, buffer, window, cx) }) } - } }); } })) diff --git a/crates/go_to_line/src/go_to_line.rs b/crates/go_to_line/src/go_to_line.rs index 1ac933e316..79f745c6df 100644 --- a/crates/go_to_line/src/go_to_line.rs +++ b/crates/go_to_line/src/go_to_line.rs @@ -103,12 +103,11 @@ impl GoToLine { return; }; editor.update(cx, |editor, cx| { - if let Some(placeholder_text) = editor.placeholder_text() { - if editor.text(cx).is_empty() { + if let Some(placeholder_text) = editor.placeholder_text() + && editor.text(cx).is_empty() { let placeholder_text = placeholder_text.to_string(); editor.set_text(placeholder_text, window, cx); } - } }); } }) diff --git a/crates/google_ai/src/google_ai.rs b/crates/google_ai/src/google_ai.rs index dfa51d024c..5f1077edc1 100644 --- a/crates/google_ai/src/google_ai.rs +++ b/crates/google_ai/src/google_ai.rs @@ -106,11 +106,9 @@ pub fn validate_generate_content_request(request: &GenerateContentRequest) -> Re .contents .iter() .find(|content| content.role == Role::User) - { - if user_content.parts.is_empty() { + && user_content.parts.is_empty() { bail!("User content must contain at least one part"); } - } Ok(()) } diff --git a/crates/gpui/build.rs b/crates/gpui/build.rs index 3a80ee12a0..0040046f90 100644 --- a/crates/gpui/build.rs +++ b/crates/gpui/build.rs @@ -327,10 +327,10 @@ mod windows { /// You can set the `GPUI_FXC_PATH` environment variable to specify the path to the fxc.exe compiler. fn find_fxc_compiler() -> String { // Check environment variable - if let Ok(path) = std::env::var("GPUI_FXC_PATH") { - if Path::new(&path).exists() { - return path; - } + if let Ok(path) = std::env::var("GPUI_FXC_PATH") + && Path::new(&path).exists() + { + return path; } // Try to find in PATH @@ -338,11 +338,10 @@ mod windows { if let Ok(output) = std::process::Command::new("where.exe") .arg("fxc.exe") .output() + && output.status.success() { - if output.status.success() { - let path = String::from_utf8_lossy(&output.stdout); - return path.trim().to_string(); - } + let path = String::from_utf8_lossy(&output.stdout); + return path.trim().to_string(); } // Check the default path diff --git a/crates/gpui/examples/input.rs b/crates/gpui/examples/input.rs index 170df3cad7..82bb10a92b 100644 --- a/crates/gpui/examples/input.rs +++ b/crates/gpui/examples/input.rs @@ -549,11 +549,10 @@ impl Element for TextElement { line.paint(bounds.origin, window.line_height(), window, cx) .unwrap(); - if focus_handle.is_focused(window) { - if let Some(cursor) = prepaint.cursor.take() { + if focus_handle.is_focused(window) + && let Some(cursor) = prepaint.cursor.take() { window.paint_quad(cursor); } - } self.input.update(cx, |input, _cx| { input.last_layout = Some(line); diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index ed1b935c58..4034761339 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1516,13 +1516,12 @@ impl App { /// the bindings in the element tree, and any global action listeners. pub fn is_action_available(&mut self, action: &dyn Action) -> bool { let mut action_available = false; - if let Some(window) = self.active_window() { - if let Ok(window_action_available) = + if let Some(window) = self.active_window() + && let Ok(window_action_available) = window.update(self, |_, window, cx| window.is_action_available(action, cx)) { action_available = window_action_available; } - } action_available || self @@ -1606,8 +1605,8 @@ impl App { .insert(action.as_any().type_id(), global_listeners); } - if self.propagate_event { - if let Some(mut global_listeners) = self + if self.propagate_event + && let Some(mut global_listeners) = self .global_action_listeners .remove(&action.as_any().type_id()) { @@ -1627,7 +1626,6 @@ impl App { self.global_action_listeners .insert(action.as_any().type_id(), global_listeners); } - } } /// Is there currently something being dragged? diff --git a/crates/gpui/src/app/context.rs b/crates/gpui/src/app/context.rs index 68c41592b3..235f048faa 100644 --- a/crates/gpui/src/app/context.rs +++ b/crates/gpui/src/app/context.rs @@ -610,8 +610,8 @@ impl<'a, T: 'static> Context<'a, T> { let (subscription, activate) = window.new_focus_listener(Box::new(move |event, window, cx| { view.update(cx, |view, cx| { - if let Some(blurred_id) = event.previous_focus_path.last().copied() { - if event.is_focus_out(focus_id) { + if let Some(blurred_id) = event.previous_focus_path.last().copied() + && event.is_focus_out(focus_id) { let event = FocusOutEvent { blurred: WeakFocusHandle { id: blurred_id, @@ -620,7 +620,6 @@ impl<'a, T: 'static> Context<'a, T> { }; listener(view, event, window, cx) } - } }) .is_ok() })); diff --git a/crates/gpui/src/element.rs b/crates/gpui/src/element.rs index e5f49c7be1..d74de73556 100644 --- a/crates/gpui/src/element.rs +++ b/crates/gpui/src/element.rs @@ -603,11 +603,10 @@ impl AnyElement { self.0.prepaint(window, cx); - if !focus_assigned { - if let Some(focus_id) = window.next_frame.focus { + if !focus_assigned + && let Some(focus_id) = window.next_frame.focus { return FocusHandle::for_id(focus_id, &cx.focus_handles); } - } None } diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs index f553bf55f6..6f1164d482 100644 --- a/crates/gpui/src/elements/div.rs +++ b/crates/gpui/src/elements/div.rs @@ -286,9 +286,9 @@ impl Interactivity { { self.mouse_move_listeners .push(Box::new(move |event, phase, hitbox, window, cx| { - if phase == DispatchPhase::Capture { - if let Some(drag) = &cx.active_drag { - if drag.value.as_ref().type_id() == TypeId::of::() { + if phase == DispatchPhase::Capture + && let Some(drag) = &cx.active_drag + && drag.value.as_ref().type_id() == TypeId::of::() { (listener)( &DragMoveEvent { event: event.clone(), @@ -300,8 +300,6 @@ impl Interactivity { cx, ); } - } - } })); } @@ -1514,8 +1512,8 @@ impl Interactivity { let mut element_state = element_state.map(|element_state| element_state.unwrap_or_default()); - if let Some(element_state) = element_state.as_ref() { - if cx.has_active_drag() { + if let Some(element_state) = element_state.as_ref() + && cx.has_active_drag() { if let Some(pending_mouse_down) = element_state.pending_mouse_down.as_ref() { *pending_mouse_down.borrow_mut() = None; @@ -1524,14 +1522,13 @@ impl Interactivity { *clicked_state.borrow_mut() = ElementClickedState::default(); } } - } // Ensure we store a focus handle in our element state if we're focusable. // If there's an explicit focus handle we're tracking, use that. Otherwise // create a new handle and store it in the element state, which lives for as // as frames contain an element with this id. - if self.focusable && self.tracked_focus_handle.is_none() { - if let Some(element_state) = element_state.as_mut() { + if self.focusable && self.tracked_focus_handle.is_none() + && let Some(element_state) = element_state.as_mut() { let mut handle = element_state .focus_handle .get_or_insert_with(|| cx.focus_handle()) @@ -1544,14 +1541,12 @@ impl Interactivity { self.tracked_focus_handle = Some(handle); } - } if let Some(scroll_handle) = self.tracked_scroll_handle.as_ref() { self.scroll_offset = Some(scroll_handle.0.borrow().offset.clone()); - } else if self.base_style.overflow.x == Some(Overflow::Scroll) - || self.base_style.overflow.y == Some(Overflow::Scroll) - { - if let Some(element_state) = element_state.as_mut() { + } else if (self.base_style.overflow.x == Some(Overflow::Scroll) + || self.base_style.overflow.y == Some(Overflow::Scroll)) + && let Some(element_state) = element_state.as_mut() { self.scroll_offset = Some( element_state .scroll_offset @@ -1559,7 +1554,6 @@ impl Interactivity { .clone(), ); } - } let style = self.compute_style_internal(None, element_state.as_mut(), window, cx); let layout_id = f(style, window, cx); @@ -2031,8 +2025,8 @@ impl Interactivity { let hitbox = hitbox.clone(); window.on_mouse_event({ move |_: &MouseUpEvent, phase, window, cx| { - if let Some(drag) = &cx.active_drag { - if phase == DispatchPhase::Bubble && hitbox.is_hovered(window) { + if let Some(drag) = &cx.active_drag + && phase == DispatchPhase::Bubble && hitbox.is_hovered(window) { let drag_state_type = drag.value.as_ref().type_id(); for (drop_state_type, listener) in &drop_listeners { if *drop_state_type == drag_state_type { @@ -2054,7 +2048,6 @@ impl Interactivity { } } } - } } }); } @@ -2094,12 +2087,11 @@ impl Interactivity { } let mut pending_mouse_down = pending_mouse_down.borrow_mut(); - if let Some(mouse_down) = pending_mouse_down.clone() { - if !cx.has_active_drag() + if let Some(mouse_down) = pending_mouse_down.clone() + && !cx.has_active_drag() && (event.position - mouse_down.position).magnitude() > DRAG_THRESHOLD - { - if let Some((drag_value, drag_listener)) = drag_listener.take() { + && let Some((drag_value, drag_listener)) = drag_listener.take() { *clicked_state.borrow_mut() = ElementClickedState::default(); let cursor_offset = event.position - hitbox.origin; let drag = (drag_listener)( @@ -2118,8 +2110,6 @@ impl Interactivity { window.refresh(); cx.stop_propagation(); } - } - } } }); @@ -2428,34 +2418,29 @@ impl Interactivity { style.refine(&self.base_style); if let Some(focus_handle) = self.tracked_focus_handle.as_ref() { - if let Some(in_focus_style) = self.in_focus_style.as_ref() { - if focus_handle.within_focused(window, cx) { + if let Some(in_focus_style) = self.in_focus_style.as_ref() + && focus_handle.within_focused(window, cx) { style.refine(in_focus_style); } - } - if let Some(focus_style) = self.focus_style.as_ref() { - if focus_handle.is_focused(window) { + if let Some(focus_style) = self.focus_style.as_ref() + && focus_handle.is_focused(window) { style.refine(focus_style); } - } } if let Some(hitbox) = hitbox { if !cx.has_active_drag() { - if let Some(group_hover) = self.group_hover_style.as_ref() { - if let Some(group_hitbox_id) = GroupHitboxes::get(&group_hover.group, cx) { - if group_hitbox_id.is_hovered(window) { + if let Some(group_hover) = self.group_hover_style.as_ref() + && let Some(group_hitbox_id) = GroupHitboxes::get(&group_hover.group, cx) + && group_hitbox_id.is_hovered(window) { style.refine(&group_hover.style); } - } - } - if let Some(hover_style) = self.hover_style.as_ref() { - if hitbox.is_hovered(window) { + if let Some(hover_style) = self.hover_style.as_ref() + && hitbox.is_hovered(window) { style.refine(hover_style); } - } } if let Some(drag) = cx.active_drag.take() { @@ -2468,13 +2453,11 @@ impl Interactivity { for (state_type, group_drag_style) in &self.group_drag_over_styles { if let Some(group_hitbox_id) = GroupHitboxes::get(&group_drag_style.group, cx) - { - if *state_type == drag.value.as_ref().type_id() + && *state_type == drag.value.as_ref().type_id() && group_hitbox_id.is_hovered(window) { style.refine(&group_drag_style.style); } - } } for (state_type, build_drag_over_style) in &self.drag_over_styles { @@ -2495,17 +2478,15 @@ impl Interactivity { .clicked_state .get_or_insert_with(Default::default) .borrow(); - if clicked_state.group { - if let Some(group) = self.group_active_style.as_ref() { + if clicked_state.group + && let Some(group) = self.group_active_style.as_ref() { style.refine(&group.style) } - } - if let Some(active_style) = self.active_style.as_ref() { - if clicked_state.element { + if let Some(active_style) = self.active_style.as_ref() + && clicked_state.element { style.refine(active_style) } - } } style diff --git a/crates/gpui/src/elements/image_cache.rs b/crates/gpui/src/elements/image_cache.rs index e7bdeaf9eb..4e15190f0f 100644 --- a/crates/gpui/src/elements/image_cache.rs +++ b/crates/gpui/src/elements/image_cache.rs @@ -297,11 +297,10 @@ impl RetainAllImageCache { /// Remove the image from the cache by the given source. pub fn remove(&mut self, source: &Resource, window: &mut Window, cx: &mut App) { let hash = hash(source); - if let Some(mut item) = self.0.remove(&hash) { - if let Some(Ok(image)) = item.get() { + if let Some(mut item) = self.0.remove(&hash) + && let Some(Ok(image)) = item.get() { cx.drop_image(image, Some(window)); } - } } /// Returns the number of images in the cache. diff --git a/crates/gpui/src/elements/img.rs b/crates/gpui/src/elements/img.rs index 993b319b69..a5b1823813 100644 --- a/crates/gpui/src/elements/img.rs +++ b/crates/gpui/src/elements/img.rs @@ -379,14 +379,13 @@ impl Element for Img { None => { if let Some(state) = &mut state { if let Some((started_loading, _)) = state.started_loading { - if started_loading.elapsed() > LOADING_DELAY { - if let Some(loading) = self.style.loading.as_ref() { + if started_loading.elapsed() > LOADING_DELAY + && let Some(loading) = self.style.loading.as_ref() { let mut element = loading(); replacement_id = Some(element.request_layout(window, cx)); layout_state.replacement = Some(element); } - } } else { let current_view = window.current_view(); let task = window.spawn(cx, async move |cx| { diff --git a/crates/gpui/src/elements/list.rs b/crates/gpui/src/elements/list.rs index 39f38bdc69..68a314caad 100644 --- a/crates/gpui/src/elements/list.rs +++ b/crates/gpui/src/elements/list.rs @@ -732,8 +732,8 @@ impl StateInner { item.element.prepaint_at(item_origin, window, cx); }); - if let Some(autoscroll_bounds) = window.take_autoscroll() { - if autoscroll { + if let Some(autoscroll_bounds) = window.take_autoscroll() + && autoscroll { if autoscroll_bounds.top() < bounds.top() { return Err(ListOffset { item_ix: item.index, @@ -773,7 +773,6 @@ impl StateInner { }); } } - } item_origin.y += item.size.height; } diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rs index 014f617e2c..4b007168b5 100644 --- a/crates/gpui/src/elements/text.rs +++ b/crates/gpui/src/elements/text.rs @@ -356,13 +356,12 @@ impl TextLayout { (None, "".into()) }; - if let Some(text_layout) = element_state.0.borrow().as_ref() { - if text_layout.size.is_some() + if let Some(text_layout) = element_state.0.borrow().as_ref() + && text_layout.size.is_some() && (wrap_width.is_none() || wrap_width == text_layout.wrap_width) { return text_layout.size.unwrap(); } - } let mut line_wrapper = cx.text_system().line_wrapper(text_style.font(), font_size); let text = if let Some(truncate_width) = truncate_width { @@ -763,15 +762,14 @@ impl Element for InteractiveText { let mut interactive_state = interactive_state.unwrap_or_default(); if let Some(click_listener) = self.click_listener.take() { let mouse_position = window.mouse_position(); - if let Ok(ix) = text_layout.index_for_position(mouse_position) { - if self + if let Ok(ix) = text_layout.index_for_position(mouse_position) + && self .clickable_ranges .iter() .any(|range| range.contains(&ix)) { window.set_cursor_style(crate::CursorStyle::PointingHand, hitbox) } - } let text_layout = text_layout.clone(); let mouse_down = interactive_state.mouse_down_index.clone(); @@ -803,14 +801,13 @@ impl Element for InteractiveText { } else { let hitbox = hitbox.clone(); window.on_mouse_event(move |event: &MouseDownEvent, phase, window, _| { - if phase == DispatchPhase::Bubble && hitbox.is_hovered(window) { - if let Ok(mouse_down_index) = + if phase == DispatchPhase::Bubble && hitbox.is_hovered(window) + && let Ok(mouse_down_index) = text_layout.index_for_position(event.position) { mouse_down.set(Some(mouse_down_index)); window.refresh(); } - } }); } } diff --git a/crates/gpui/src/keymap/binding.rs b/crates/gpui/src/keymap/binding.rs index 1d3f612c5b..133c1f5a45 100644 --- a/crates/gpui/src/keymap/binding.rs +++ b/crates/gpui/src/keymap/binding.rs @@ -53,11 +53,10 @@ impl KeyBinding { if let Some(equivalents) = key_equivalents { for keystroke in keystrokes.iter_mut() { - if keystroke.key.chars().count() == 1 { - if let Some(key) = equivalents.get(&keystroke.key.chars().next().unwrap()) { + if keystroke.key.chars().count() == 1 + && let Some(key) = equivalents.get(&keystroke.key.chars().next().unwrap()) { keystroke.key = key.to_string(); } - } } } diff --git a/crates/gpui/src/platform/blade/blade_renderer.rs b/crates/gpui/src/platform/blade/blade_renderer.rs index 46d3c16c72..bd632860d0 100644 --- a/crates/gpui/src/platform/blade/blade_renderer.rs +++ b/crates/gpui/src/platform/blade/blade_renderer.rs @@ -434,8 +434,8 @@ impl BladeRenderer { } fn wait_for_gpu(&mut self) { - if let Some(last_sp) = self.last_sync_point.take() { - if !self.gpu.wait_for(&last_sp, MAX_FRAME_TIME_MS) { + if let Some(last_sp) = self.last_sync_point.take() + && !self.gpu.wait_for(&last_sp, MAX_FRAME_TIME_MS) { log::error!("GPU hung"); #[cfg(target_os = "linux")] if self.gpu.device_information().driver_name == "radv" { @@ -452,7 +452,6 @@ impl BladeRenderer { ); while !self.gpu.wait_for(&last_sp, MAX_FRAME_TIME_MS) {} } - } } pub fn update_drawable_size(&mut self, size: Size) { diff --git a/crates/gpui/src/platform/linux/wayland/window.rs b/crates/gpui/src/platform/linux/wayland/window.rs index 2b2207e22c..ca51da8e01 100644 --- a/crates/gpui/src/platform/linux/wayland/window.rs +++ b/crates/gpui/src/platform/linux/wayland/window.rs @@ -718,16 +718,15 @@ impl WaylandWindowStatePtr { return; } } - if let PlatformInput::KeyDown(event) = input { - if event.keystroke.modifiers.is_subset_of(&Modifiers::shift()) { - if let Some(key_char) = &event.keystroke.key_char { - let mut state = self.state.borrow_mut(); - if let Some(mut input_handler) = state.input_handler.take() { - drop(state); - input_handler.replace_text_in_range(None, key_char); - self.state.borrow_mut().input_handler = Some(input_handler); - } - } + if let PlatformInput::KeyDown(event) = input + && event.keystroke.modifiers.is_subset_of(&Modifiers::shift()) + && let Some(key_char) = &event.keystroke.key_char + { + let mut state = self.state.borrow_mut(); + if let Some(mut input_handler) = state.input_handler.take() { + drop(state); + input_handler.replace_text_in_range(None, key_char); + self.state.borrow_mut().input_handler = Some(input_handler); } } } diff --git a/crates/gpui/src/platform/mac/open_type.rs b/crates/gpui/src/platform/mac/open_type.rs index 2ae5e8f87a..173f8863f3 100644 --- a/crates/gpui/src/platform/mac/open_type.rs +++ b/crates/gpui/src/platform/mac/open_type.rs @@ -35,15 +35,14 @@ pub fn apply_features_and_fallbacks( unsafe { let mut keys = vec![kCTFontFeatureSettingsAttribute]; let mut values = vec![generate_feature_array(features)]; - if let Some(fallbacks) = fallbacks { - if !fallbacks.fallback_list().is_empty() { + if let Some(fallbacks) = fallbacks + && !fallbacks.fallback_list().is_empty() { keys.push(kCTFontCascadeListAttribute); values.push(generate_fallback_array( fallbacks, font.native_font().as_concrete_TypeRef(), )); } - } let attrs = CFDictionaryCreate( kCFAllocatorDefault, keys.as_ptr() as _, diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rs index f094ed9f30..2bdfc7a84b 100644 --- a/crates/gpui/src/platform/mac/platform.rs +++ b/crates/gpui/src/platform/mac/platform.rs @@ -715,11 +715,10 @@ impl Platform for MacPlatform { let urls = panel.URLs(); for i in 0..urls.count() { let url = urls.objectAtIndex(i); - if url.isFileURL() == YES { - if let Ok(path) = ns_url_to_path(url) { + if url.isFileURL() == YES + && let Ok(path) = ns_url_to_path(url) { result.push(path) } - } } Some(result) } else { @@ -786,8 +785,8 @@ impl Platform for MacPlatform { // This is conditional on OS version because I'd like to get rid of it, so that // you can manually create a file called `a.sql.s`. That said it seems better // to break that use-case than breaking `a.sql`. - if chunks.len() == 3 && chunks[1].starts_with(chunks[2]) { - if Self::os_version() >= SemanticVersion::new(15, 0, 0) { + if chunks.len() == 3 && chunks[1].starts_with(chunks[2]) + && Self::os_version() >= SemanticVersion::new(15, 0, 0) { let new_filename = OsStr::from_bytes( &filename.as_bytes() [..chunks[0].len() + 1 + chunks[1].len()], @@ -795,7 +794,6 @@ impl Platform for MacPlatform { .to_owned(); result.set_file_name(&new_filename); } - } return result; }) } diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 40a03b6c4a..99d80a76df 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -1478,8 +1478,8 @@ extern "C" fn handle_key_event(this: &Object, native_event: id, key_equivalent: return YES; } - if key_down_event.is_held { - if let Some(key_char) = key_down_event.keystroke.key_char.as_ref() { + if key_down_event.is_held + && let Some(key_char) = key_down_event.keystroke.key_char.as_ref() { let handled = with_input_handler(this, |input_handler| { if !input_handler.apple_press_and_hold_enabled() { input_handler.replace_text_in_range(None, key_char); @@ -1491,7 +1491,6 @@ extern "C" fn handle_key_event(this: &Object, native_event: id, key_equivalent: return YES; } } - } // Don't send key equivalents to the input handler, // or macOS shortcuts like cmd-` will stop working. @@ -1624,11 +1623,9 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) { modifiers: prev_modifiers, capslock: prev_capslock, })) = &lock.previous_modifiers_changed_event - { - if prev_modifiers == modifiers && prev_capslock == capslock { + && prev_modifiers == modifiers && prev_capslock == capslock { return; } - } lock.previous_modifiers_changed_event = Some(event.clone()); } @@ -1995,11 +1992,10 @@ extern "C" fn attributed_substring_for_proposed_range( let mut adjusted: Option> = None; let selected_text = input_handler.text_for_range(range.clone(), &mut adjusted)?; - if let Some(adjusted) = adjusted { - if adjusted != range { + if let Some(adjusted) = adjusted + && adjusted != range { unsafe { (actual_range as *mut NSRange).write(NSRange::from(adjusted)) }; } - } unsafe { let string: id = msg_send![class!(NSAttributedString), alloc]; let string: id = msg_send![string, initWithString: ns_string(&selected_text)]; @@ -2073,12 +2069,10 @@ extern "C" fn dragging_entered(this: &Object, _: Sel, dragging_info: id) -> NSDr let paths = external_paths_from_event(dragging_info); if let Some(event) = paths.map(|paths| PlatformInput::FileDrop(FileDropEvent::Entered { position, paths })) - { - if send_new_event(&window_state, event) { + && send_new_event(&window_state, event) { window_state.lock().external_files_dragged = true; return NSDragOperationCopy; } - } NSDragOperationNone } diff --git a/crates/gpui/src/platform/test/dispatcher.rs b/crates/gpui/src/platform/test/dispatcher.rs index 16edabfa4b..91e36547db 100644 --- a/crates/gpui/src/platform/test/dispatcher.rs +++ b/crates/gpui/src/platform/test/dispatcher.rs @@ -78,12 +78,11 @@ impl TestDispatcher { let state = self.state.lock(); let next_due_time = state.delayed.first().map(|(time, _)| *time); drop(state); - if let Some(due_time) = next_due_time { - if due_time <= new_now { + if let Some(due_time) = next_due_time + && due_time <= new_now { self.state.lock().time = due_time; continue; } - } break; } self.state.lock().time = new_now; diff --git a/crates/gpui/src/platform/test/platform.rs b/crates/gpui/src/platform/test/platform.rs index 69371bc8c4..7d75eddcb3 100644 --- a/crates/gpui/src/platform/test/platform.rs +++ b/crates/gpui/src/platform/test/platform.rs @@ -201,11 +201,10 @@ impl TestPlatform { executor .spawn(async move { if let Some(previous_window) = previous_window { - if let Some(window) = window.as_ref() { - if Rc::ptr_eq(&previous_window.0, &window.0) { + if let Some(window) = window.as_ref() + && Rc::ptr_eq(&previous_window.0, &window.0) { return; } - } previous_window.simulate_active_status_change(false); } if let Some(window) = window { diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index 9b25ab360e..c3bb8bb22b 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -701,29 +701,28 @@ impl WindowsWindowInner { // Fix auto hide taskbar not showing. This solution is based on the approach // used by Chrome. However, it may result in one row of pixels being obscured // in our client area. But as Chrome says, "there seems to be no better solution." - if is_maximized { - if let Some(ref taskbar_position) = self + if is_maximized + && let Some(ref taskbar_position) = self .state .borrow() .system_settings .auto_hide_taskbar_position - { - // Fot the auto-hide taskbar, adjust in by 1 pixel on taskbar edge, - // so the window isn't treated as a "fullscreen app", which would cause - // the taskbar to disappear. - match taskbar_position { - AutoHideTaskbarPosition::Left => { - requested_client_rect[0].left += AUTO_HIDE_TASKBAR_THICKNESS_PX - } - AutoHideTaskbarPosition::Top => { - requested_client_rect[0].top += AUTO_HIDE_TASKBAR_THICKNESS_PX - } - AutoHideTaskbarPosition::Right => { - requested_client_rect[0].right -= AUTO_HIDE_TASKBAR_THICKNESS_PX - } - AutoHideTaskbarPosition::Bottom => { - requested_client_rect[0].bottom -= AUTO_HIDE_TASKBAR_THICKNESS_PX - } + { + // Fot the auto-hide taskbar, adjust in by 1 pixel on taskbar edge, + // so the window isn't treated as a "fullscreen app", which would cause + // the taskbar to disappear. + match taskbar_position { + AutoHideTaskbarPosition::Left => { + requested_client_rect[0].left += AUTO_HIDE_TASKBAR_THICKNESS_PX + } + AutoHideTaskbarPosition::Top => { + requested_client_rect[0].top += AUTO_HIDE_TASKBAR_THICKNESS_PX + } + AutoHideTaskbarPosition::Right => { + requested_client_rect[0].right -= AUTO_HIDE_TASKBAR_THICKNESS_PX + } + AutoHideTaskbarPosition::Bottom => { + requested_client_rect[0].bottom -= AUTO_HIDE_TASKBAR_THICKNESS_PX } } } @@ -1125,28 +1124,26 @@ impl WindowsWindowInner { // lParam is a pointer to a string that indicates the area containing the system parameter // that was changed. let parameter = PCWSTR::from_raw(lparam.0 as _); - if unsafe { !parameter.is_null() && !parameter.is_empty() } { - if let Some(parameter_string) = unsafe { parameter.to_string() }.log_err() { - log::info!("System settings changed: {}", parameter_string); - match parameter_string.as_str() { - "ImmersiveColorSet" => { - let new_appearance = system_appearance() - .context( - "unable to get system appearance when handling ImmersiveColorSet", - ) - .log_err()?; - let mut lock = self.state.borrow_mut(); - if new_appearance != lock.appearance { - lock.appearance = new_appearance; - let mut callback = lock.callbacks.appearance_changed.take()?; - drop(lock); - callback(); - self.state.borrow_mut().callbacks.appearance_changed = Some(callback); - configure_dwm_dark_mode(handle, new_appearance); - } + if unsafe { !parameter.is_null() && !parameter.is_empty() } + && let Some(parameter_string) = unsafe { parameter.to_string() }.log_err() + { + log::info!("System settings changed: {}", parameter_string); + match parameter_string.as_str() { + "ImmersiveColorSet" => { + let new_appearance = system_appearance() + .context("unable to get system appearance when handling ImmersiveColorSet") + .log_err()?; + let mut lock = self.state.borrow_mut(); + if new_appearance != lock.appearance { + lock.appearance = new_appearance; + let mut callback = lock.callbacks.appearance_changed.take()?; + drop(lock); + callback(); + self.state.borrow_mut().callbacks.appearance_changed = Some(callback); + configure_dwm_dark_mode(handle, new_appearance); } - _ => {} } + _ => {} } } Some(0) diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs index 856187fa57..b13b9915f1 100644 --- a/crates/gpui/src/platform/windows/platform.rs +++ b/crates/gpui/src/platform/windows/platform.rs @@ -821,14 +821,14 @@ fn file_save_dialog( window: Option, ) -> Result> { let dialog: IFileSaveDialog = unsafe { CoCreateInstance(&FileSaveDialog, None, CLSCTX_ALL)? }; - if !directory.to_string_lossy().is_empty() { - if let Some(full_path) = directory.canonicalize().log_err() { - let full_path = SanitizedPath::from(full_path); - let full_path_string = full_path.to_string(); - let path_item: IShellItem = - unsafe { SHCreateItemFromParsingName(&HSTRING::from(full_path_string), None)? }; - unsafe { dialog.SetFolder(&path_item).log_err() }; - } + if !directory.to_string_lossy().is_empty() + && let Some(full_path) = directory.canonicalize().log_err() + { + let full_path = SanitizedPath::from(full_path); + let full_path_string = full_path.to_string(); + let path_item: IShellItem = + unsafe { SHCreateItemFromParsingName(&HSTRING::from(full_path_string), None)? }; + unsafe { dialog.SetFolder(&path_item).log_err() }; } if let Some(suggested_name) = suggested_name { diff --git a/crates/gpui/src/text_system.rs b/crates/gpui/src/text_system.rs index b48c3a2935..433d20336e 100644 --- a/crates/gpui/src/text_system.rs +++ b/crates/gpui/src/text_system.rs @@ -366,8 +366,8 @@ impl WindowTextSystem { let mut decoration_runs = SmallVec::<[DecorationRun; 32]>::new(); for run in runs { - if let Some(last_run) = decoration_runs.last_mut() { - if last_run.color == run.color + if let Some(last_run) = decoration_runs.last_mut() + && last_run.color == run.color && last_run.underline == run.underline && last_run.strikethrough == run.strikethrough && last_run.background_color == run.background_color @@ -375,7 +375,6 @@ impl WindowTextSystem { last_run.len += run.len as u32; continue; } - } decoration_runs.push(DecorationRun { len: run.len as u32, color: run.color, @@ -492,8 +491,8 @@ impl WindowTextSystem { let mut split_lines = text.split('\n'); let mut processed = false; - if let Some(first_line) = split_lines.next() { - if let Some(second_line) = split_lines.next() { + if let Some(first_line) = split_lines.next() + && let Some(second_line) = split_lines.next() { processed = true; process_line(first_line.to_string().into()); process_line(second_line.to_string().into()); @@ -501,7 +500,6 @@ impl WindowTextSystem { process_line(line_text.to_string().into()); } } - } if !processed { process_line(text); @@ -534,12 +532,11 @@ impl WindowTextSystem { let mut font_runs = self.font_runs_pool.lock().pop().unwrap_or_default(); for run in runs.iter() { let font_id = self.resolve_font(&run.font); - if let Some(last_run) = font_runs.last_mut() { - if last_run.font_id == font_id { + if let Some(last_run) = font_runs.last_mut() + && last_run.font_id == font_id { last_run.len += run.len; continue; } - } font_runs.push(FontRun { len: run.len, font_id, diff --git a/crates/gpui/src/text_system/line.rs b/crates/gpui/src/text_system/line.rs index 3813393d81..1ab096372b 100644 --- a/crates/gpui/src/text_system/line.rs +++ b/crates/gpui/src/text_system/line.rs @@ -292,11 +292,10 @@ fn paint_line( } if let Some(style_run) = style_run { - if let Some((_, underline_style)) = &mut current_underline { - if style_run.underline.as_ref() != Some(underline_style) { + if let Some((_, underline_style)) = &mut current_underline + && style_run.underline.as_ref() != Some(underline_style) { finished_underline = current_underline.take(); } - } if let Some(run_underline) = style_run.underline.as_ref() { current_underline.get_or_insert(( point( @@ -310,11 +309,10 @@ fn paint_line( }, )); } - if let Some((_, strikethrough_style)) = &mut current_strikethrough { - if style_run.strikethrough.as_ref() != Some(strikethrough_style) { + if let Some((_, strikethrough_style)) = &mut current_strikethrough + && style_run.strikethrough.as_ref() != Some(strikethrough_style) { finished_strikethrough = current_strikethrough.take(); } - } if let Some(run_strikethrough) = style_run.strikethrough.as_ref() { current_strikethrough.get_or_insert(( point( @@ -509,11 +507,10 @@ fn paint_line_background( } if let Some(style_run) = style_run { - if let Some((_, background_color)) = &mut current_background { - if style_run.background_color.as_ref() != Some(background_color) { + if let Some((_, background_color)) = &mut current_background + && style_run.background_color.as_ref() != Some(background_color) { finished_background = current_background.take(); } - } if let Some(run_background) = style_run.background_color { current_background.get_or_insert(( point(glyph_origin.x, glyph_origin.y), diff --git a/crates/gpui/src/text_system/line_layout.rs b/crates/gpui/src/text_system/line_layout.rs index 9c2dd7f087..61804876a8 100644 --- a/crates/gpui/src/text_system/line_layout.rs +++ b/crates/gpui/src/text_system/line_layout.rs @@ -185,11 +185,10 @@ impl LineLayout { if width > wrap_width && boundary > last_boundary { // When used line_clamp, we should limit the number of lines. - if let Some(max_lines) = max_lines { - if boundaries.len() >= max_lines - 1 { + if let Some(max_lines) = max_lines + && boundaries.len() >= max_lines - 1 { break; } - } if let Some(last_candidate_ix) = last_candidate_ix.take() { last_boundary = last_candidate_ix; diff --git a/crates/gpui/src/view.rs b/crates/gpui/src/view.rs index f461e2f7d0..4bcaf0e262 100644 --- a/crates/gpui/src/view.rs +++ b/crates/gpui/src/view.rs @@ -205,8 +205,8 @@ impl Element for AnyView { let content_mask = window.content_mask(); let text_style = window.text_style(); - if let Some(mut element_state) = element_state { - if element_state.cache_key.bounds == bounds + if let Some(mut element_state) = element_state + && element_state.cache_key.bounds == bounds && element_state.cache_key.content_mask == content_mask && element_state.cache_key.text_style == text_style && !window.dirty_views.contains(&self.entity_id()) @@ -221,7 +221,6 @@ impl Element for AnyView { return (None, element_state); } - } let refreshing = mem::replace(&mut window.refreshing, true); let prepaint_start = window.prepaint_index(); diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index c0ffd34a0d..56d634ec3f 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -3401,8 +3401,8 @@ impl Window { let focus_id = handle.id; let (subscription, activate) = self.new_focus_listener(Box::new(move |event, window, cx| { - if let Some(blurred_id) = event.previous_focus_path.last().copied() { - if event.is_focus_out(focus_id) { + if let Some(blurred_id) = event.previous_focus_path.last().copied() + && event.is_focus_out(focus_id) { let event = FocusOutEvent { blurred: WeakFocusHandle { id: blurred_id, @@ -3411,7 +3411,6 @@ impl Window { }; listener(event, window, cx) } - } true })); cx.defer(move |_| activate()); @@ -3444,13 +3443,12 @@ impl Window { return true; } - if let Some(input) = keystroke.key_char { - if let Some(mut input_handler) = self.platform_window.take_input_handler() { + if let Some(input) = keystroke.key_char + && let Some(mut input_handler) = self.platform_window.take_input_handler() { input_handler.dispatch_input(&input, self, cx); self.platform_window.set_input_handler(input_handler); return true; } - } false } @@ -3864,12 +3862,11 @@ impl Window { if !cx.propagate_event { continue 'replay; } - if let Some(input) = replay.keystroke.key_char.as_ref().cloned() { - if let Some(mut input_handler) = self.platform_window.take_input_handler() { + if let Some(input) = replay.keystroke.key_char.as_ref().cloned() + && let Some(mut input_handler) = self.platform_window.take_input_handler() { input_handler.dispatch_input(&input, self, cx); self.platform_window.set_input_handler(input_handler) } - } } } @@ -4309,8 +4306,8 @@ impl Window { cx: &mut App, f: impl FnOnce(&mut Option, &mut Self) -> R, ) -> R { - if let Some(inspector_id) = _inspector_id { - if let Some(inspector) = &self.inspector { + if let Some(inspector_id) = _inspector_id + && let Some(inspector) = &self.inspector { let inspector = inspector.clone(); let active_element_id = inspector.read(cx).active_element_id(); if Some(inspector_id) == active_element_id { @@ -4319,7 +4316,6 @@ impl Window { }); } } - } f(&mut None, self) } @@ -4389,8 +4385,7 @@ impl Window { if let Some(inspector) = self.inspector.as_ref() { let inspector = inspector.read(cx); if let Some((hitbox_id, _)) = self.hovered_inspector_hitbox(inspector, &self.next_frame) - { - if let Some(hitbox) = self + && let Some(hitbox) = self .next_frame .hitboxes .iter() @@ -4398,7 +4393,6 @@ impl Window { { self.paint_quad(crate::fill(hitbox.bounds, crate::rgba(0x61afef4d))); } - } } } diff --git a/crates/gpui_macros/src/derive_inspector_reflection.rs b/crates/gpui_macros/src/derive_inspector_reflection.rs index fa22f95f9a..293119bfec 100644 --- a/crates/gpui_macros/src/derive_inspector_reflection.rs +++ b/crates/gpui_macros/src/derive_inspector_reflection.rs @@ -160,17 +160,14 @@ fn extract_doc_comment(attrs: &[Attribute]) -> Option { let mut doc_lines = Vec::new(); for attr in attrs { - if attr.path().is_ident("doc") { - if let Meta::NameValue(meta) = &attr.meta { - if let Expr::Lit(expr_lit) = &meta.value { - if let Lit::Str(lit_str) = &expr_lit.lit { + if attr.path().is_ident("doc") + && let Meta::NameValue(meta) = &attr.meta + && let Expr::Lit(expr_lit) = &meta.value + && let Lit::Str(lit_str) = &expr_lit.lit { let line = lit_str.value(); let line = line.strip_prefix(' ').unwrap_or(&line); doc_lines.push(line.to_string()); } - } - } - } } if doc_lines.is_empty() { diff --git a/crates/gpui_macros/src/test.rs b/crates/gpui_macros/src/test.rs index 5a8b1cf7fc..8aabaeeeee 100644 --- a/crates/gpui_macros/src/test.rs +++ b/crates/gpui_macros/src/test.rs @@ -152,8 +152,8 @@ fn generate_test_function( } _ => {} } - } else if let Type::Reference(ty) = &*arg.ty { - if let Type::Path(ty) = &*ty.elem { + } else if let Type::Reference(ty) = &*arg.ty + && let Type::Path(ty) = &*ty.elem { let last_segment = ty.path.segments.last(); if let Some("TestAppContext") = last_segment.map(|s| s.ident.to_string()).as_deref() @@ -175,7 +175,6 @@ fn generate_test_function( continue; } } - } } return Err(error_with_message("invalid function signature", arg)); @@ -215,8 +214,8 @@ fn generate_test_function( inner_fn_args.extend(quote!(rand::SeedableRng::seed_from_u64(_seed),)); continue; } - } else if let Type::Reference(ty) = &*arg.ty { - if let Type::Path(ty) = &*ty.elem { + } else if let Type::Reference(ty) = &*arg.ty + && let Type::Path(ty) = &*ty.elem { let last_segment = ty.path.segments.last(); match last_segment.map(|s| s.ident.to_string()).as_deref() { Some("App") => { @@ -258,7 +257,6 @@ fn generate_test_function( _ => {} } } - } } return Err(error_with_message("invalid function signature", arg)); diff --git a/crates/html_to_markdown/src/markdown.rs b/crates/html_to_markdown/src/markdown.rs index b9ffbac79c..5d1aed57e6 100644 --- a/crates/html_to_markdown/src/markdown.rs +++ b/crates/html_to_markdown/src/markdown.rs @@ -34,16 +34,14 @@ impl HandleTag for ParagraphHandler { tag: &HtmlElement, writer: &mut MarkdownWriter, ) -> StartTagOutcome { - if tag.is_inline() && writer.is_inside("p") { - if let Some(parent) = writer.current_element_stack().iter().last() { - if !(parent.is_inline() + if tag.is_inline() && writer.is_inside("p") + && let Some(parent) = writer.current_element_stack().iter().last() + && !(parent.is_inline() || writer.markdown.ends_with(' ') || writer.markdown.ends_with('\n')) { writer.push_str(" "); } - } - } if tag.tag() == "p" { writer.push_blank_line() diff --git a/crates/http_client/src/github.rs b/crates/http_client/src/github.rs index 89309ff344..e604fb38bc 100644 --- a/crates/http_client/src/github.rs +++ b/crates/http_client/src/github.rs @@ -77,11 +77,10 @@ pub async fn latest_github_release( .find(|release| release.pre_release == pre_release) .context("finding a prerelease")?; release.assets.iter_mut().for_each(|asset| { - if let Some(digest) = &mut asset.digest { - if let Some(stripped) = digest.strip_prefix("sha256:") { + if let Some(digest) = &mut asset.digest + && let Some(stripped) = digest.strip_prefix("sha256:") { *digest = stripped.to_owned(); } - } }); Ok(release) } diff --git a/crates/journal/src/journal.rs b/crates/journal/src/journal.rs index 0335a746cd..3e3a36188a 100644 --- a/crates/journal/src/journal.rs +++ b/crates/journal/src/journal.rs @@ -170,8 +170,8 @@ pub fn new_journal_entry(workspace: &Workspace, window: &mut Window, cx: &mut Ap .await }; - if let Some(Some(Ok(item))) = opened.first() { - if let Some(editor) = item.downcast::().map(|editor| editor.downgrade()) { + if let Some(Some(Ok(item))) = opened.first() + && let Some(editor) = item.downcast::().map(|editor| editor.downgrade()) { editor.update_in(cx, |editor, window, cx| { let len = editor.buffer().read(cx).len(cx); editor.change_selections( @@ -187,7 +187,6 @@ pub fn new_journal_entry(workspace: &Workspace, window: &mut Window, cx: &mut Ap editor.insert("\n\n", window, cx); })?; } - } anyhow::Ok(()) }) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index abb8d3b151..e0c8a030db 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -1158,14 +1158,13 @@ impl Buffer { base_buffer.edit(edits, None, cx) }); - if let Some(operation) = operation { - if let Some(BufferBranchState { + if let Some(operation) = operation + && let Some(BufferBranchState { merged_operations, .. }) = &mut self.branch_state { merged_operations.push(operation); } - } } fn on_base_buffer_event( @@ -1185,12 +1184,11 @@ impl Buffer { }; let mut operation_to_undo = None; - if let Operation::Buffer(text::Operation::Edit(operation)) = &operation { - if let Ok(ix) = merged_operations.binary_search(&operation.timestamp) { + if let Operation::Buffer(text::Operation::Edit(operation)) = &operation + && let Ok(ix) = merged_operations.binary_search(&operation.timestamp) { merged_operations.remove(ix); operation_to_undo = Some(operation.timestamp); } - } self.apply_ops([operation.clone()], cx); @@ -1424,11 +1422,10 @@ impl Buffer { .map(|info| info.language.clone()) .collect(); - if languages.is_empty() { - if let Some(buffer_language) = self.language() { + if languages.is_empty() + && let Some(buffer_language) = self.language() { languages.push(buffer_language.clone()); } - } languages } @@ -2589,11 +2586,10 @@ impl Buffer { line_mode, cursor_shape, } => { - if let Some(set) = self.remote_selections.get(&lamport_timestamp.replica_id) { - if set.lamport_timestamp > lamport_timestamp { + if let Some(set) = self.remote_selections.get(&lamport_timestamp.replica_id) + && set.lamport_timestamp > lamport_timestamp { return; } - } self.remote_selections.insert( lamport_timestamp.replica_id, @@ -3365,8 +3361,8 @@ impl BufferSnapshot { } } - if let Some(range) = range { - if smallest_range_and_depth.as_ref().map_or( + if let Some(range) = range + && smallest_range_and_depth.as_ref().map_or( true, |(smallest_range, smallest_range_depth)| { if layer.depth > *smallest_range_depth { @@ -3384,7 +3380,6 @@ impl BufferSnapshot { override_id: layer.override_id(offset, &self.text), }); } - } } scope.or_else(|| { @@ -3499,18 +3494,16 @@ impl BufferSnapshot { // If there is a candidate node on both sides of the (empty) range, then // decide between the two by favoring a named node over an anonymous token. // If both nodes are the same in that regard, favor the right one. - if let Some(right_node) = right_node { - if right_node.is_named() || !left_node.is_named() { + if let Some(right_node) = right_node + && (right_node.is_named() || !left_node.is_named()) { layer_result = right_node; } - } } - if let Some(previous_result) = &result { - if previous_result.byte_range().len() < layer_result.byte_range().len() { + if let Some(previous_result) = &result + && previous_result.byte_range().len() < layer_result.byte_range().len() { continue; } - } result = Some(layer_result); } @@ -4081,11 +4074,10 @@ impl BufferSnapshot { let mut result: Option<(Range, Range)> = None; for pair in self.enclosing_bracket_ranges(range.clone()) { - if let Some(range_filter) = range_filter { - if !range_filter(pair.open_range.clone(), pair.close_range.clone()) { + if let Some(range_filter) = range_filter + && !range_filter(pair.open_range.clone(), pair.close_range.clone()) { continue; } - } let len = pair.close_range.end - pair.open_range.start; @@ -4474,16 +4466,14 @@ impl BufferSnapshot { current_word_start_ix = Some(ix); } - if let Some(query_chars) = &query_chars { - if query_ix < query_len { - if c.to_lowercase().eq(query_chars[query_ix].to_lowercase()) { + if let Some(query_chars) = &query_chars + && query_ix < query_len + && c.to_lowercase().eq(query_chars[query_ix].to_lowercase()) { query_ix += 1; } - } - } continue; - } else if let Some(word_start) = current_word_start_ix.take() { - if query_ix == query_len { + } else if let Some(word_start) = current_word_start_ix.take() + && query_ix == query_len { let word_range = self.anchor_before(word_start)..self.anchor_after(ix); let mut word_text = self.text_for_range(word_start..ix).peekable(); let first_char = word_text @@ -4496,7 +4486,6 @@ impl BufferSnapshot { words.insert(word_text.collect(), word_range); } } - } query_ix = 0; } chunk_ix += chunk.text.len(); @@ -4607,8 +4596,8 @@ impl<'a> BufferChunks<'a> { highlights .stack .retain(|(end_offset, _)| *end_offset > range.start); - if let Some(capture) = &highlights.next_capture { - if range.start >= capture.node.start_byte() { + if let Some(capture) = &highlights.next_capture + && range.start >= capture.node.start_byte() { let next_capture_end = capture.node.end_byte(); if range.start < next_capture_end { highlights.stack.push(( @@ -4618,7 +4607,6 @@ impl<'a> BufferChunks<'a> { } highlights.next_capture.take(); } - } } else if let Some(snapshot) = self.buffer_snapshot { let (captures, highlight_maps) = snapshot.get_highlights(self.range.clone()); *highlights = BufferChunkHighlights { @@ -4642,8 +4630,8 @@ impl<'a> BufferChunks<'a> { } fn initialize_diagnostic_endpoints(&mut self) { - if let Some(diagnostics) = self.diagnostic_endpoints.as_mut() { - if let Some(buffer) = self.buffer_snapshot { + if let Some(diagnostics) = self.diagnostic_endpoints.as_mut() + && let Some(buffer) = self.buffer_snapshot { let mut diagnostic_endpoints = Vec::new(); for entry in buffer.diagnostics_in_range::<_, usize>(self.range.clone(), false) { diagnostic_endpoints.push(DiagnosticEndpoint { @@ -4669,7 +4657,6 @@ impl<'a> BufferChunks<'a> { self.warning_depth = 0; self.information_depth = 0; } - } } /// The current byte offset in the buffer. @@ -4779,12 +4766,11 @@ impl<'a> Iterator for BufferChunks<'a> { .min(next_capture_start) .min(next_diagnostic_endpoint); let mut highlight_id = None; - if let Some(highlights) = self.highlights.as_ref() { - if let Some((parent_capture_end, parent_highlight_id)) = highlights.stack.last() { + if let Some(highlights) = self.highlights.as_ref() + && let Some((parent_capture_end, parent_highlight_id)) = highlights.stack.last() { chunk_end = chunk_end.min(*parent_capture_end); highlight_id = Some(*parent_highlight_id); } - } let slice = &chunk[chunk_start - self.chunks.offset()..chunk_end - self.chunks.offset()]; @@ -4977,12 +4963,11 @@ pub(crate) fn contiguous_ranges( std::iter::from_fn(move || { loop { if let Some(value) = values.next() { - if let Some(range) = &mut current_range { - if value == range.end && range.len() < max_len { + if let Some(range) = &mut current_range + && value == range.end && range.len() < max_len { range.end += 1; continue; } - } let prev_range = current_range.clone(); current_range = Some(value..(value + 1)); @@ -5049,11 +5034,10 @@ impl CharClassifier { } else { scope.word_characters() }; - if let Some(characters) = characters { - if characters.contains(&c) { + if let Some(characters) = characters + && characters.contains(&c) { return CharKind::Word; } - } } if c.is_whitespace() { diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index 3a41733191..02eb21cc09 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -329,8 +329,8 @@ pub trait LspAdapter: 'static + Send + Sync { // We only want to cache when we fall back to the global one, // because we don't want to download and overwrite our global one // for each worktree we might have open. - if binary_options.allow_path_lookup { - if let Some(binary) = self.check_if_user_installed(delegate.as_ref(), toolchains, cx).await { + if binary_options.allow_path_lookup + && let Some(binary) = self.check_if_user_installed(delegate.as_ref(), toolchains, cx).await { log::info!( "found user-installed language server for {}. path: {:?}, arguments: {:?}", self.name().0, @@ -339,7 +339,6 @@ pub trait LspAdapter: 'static + Send + Sync { ); return Ok(binary); } - } anyhow::ensure!(binary_options.allow_binary_download, "downloading language servers disabled"); @@ -1776,11 +1775,10 @@ impl Language { BufferChunks::new(text, range, Some((captures, highlight_maps)), false, None) { let end_offset = offset + chunk.text.len(); - if let Some(highlight_id) = chunk.syntax_highlight_id { - if !highlight_id.is_default() { + if let Some(highlight_id) = chunk.syntax_highlight_id + && !highlight_id.is_default() { result.push((offset..end_offset, highlight_id)); } - } offset = end_offset; } } @@ -1796,12 +1794,11 @@ impl Language { } pub fn set_theme(&self, theme: &SyntaxTheme) { - if let Some(grammar) = self.grammar.as_ref() { - if let Some(highlights_query) = &grammar.highlights_query { + if let Some(grammar) = self.grammar.as_ref() + && let Some(highlights_query) = &grammar.highlights_query { *grammar.highlight_map.lock() = HighlightMap::new(highlights_query.capture_names(), theme); } - } } pub fn grammar(&self) -> Option<&Arc> { @@ -1920,12 +1917,11 @@ impl LanguageScope { .enumerate() .map(move |(ix, bracket)| { let mut is_enabled = true; - if let Some(next_disabled_ix) = disabled_ids.first() { - if ix == *next_disabled_ix as usize { + if let Some(next_disabled_ix) = disabled_ids.first() + && ix == *next_disabled_ix as usize { disabled_ids = &disabled_ids[1..]; is_enabled = false; } - } (bracket, is_enabled) }) } diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index 30bbc88f7e..2ad7232f06 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -414,8 +414,8 @@ impl SyntaxSnapshot { .collect::>(); self.reparse_with_ranges(text, root_language.clone(), edit_ranges, registry.as_ref()); - if let Some(registry) = registry { - if registry.version() != self.language_registry_version { + if let Some(registry) = registry + && registry.version() != self.language_registry_version { let mut resolved_injection_ranges = Vec::new(); let mut cursor = self .layers @@ -450,7 +450,6 @@ impl SyntaxSnapshot { } self.language_registry_version = registry.version(); } - } self.update_count += 1; } @@ -1065,11 +1064,10 @@ impl<'a> SyntaxMapCaptures<'a> { pub fn set_byte_range(&mut self, range: Range) { for layer in &mut self.layers { layer.captures.set_byte_range(range.clone()); - if let Some(capture) = &layer.next_capture { - if capture.node.end_byte() > range.start { + if let Some(capture) = &layer.next_capture + && capture.node.end_byte() > range.start { continue; } - } layer.advance(); } self.layers.sort_unstable_by_key(|layer| layer.sort_key()); @@ -1277,12 +1275,11 @@ fn join_ranges( (None, None) => break, }; - if let Some(last) = result.last_mut() { - if range.start <= last.end { + if let Some(last) = result.last_mut() + && range.start <= last.end { last.end = last.end.max(range.end); continue; } - } result.push(range); } result @@ -1330,15 +1327,14 @@ fn get_injections( // if there currently no matches for that injection. combined_injection_ranges.clear(); for pattern in &config.patterns { - if let (Some(language_name), true) = (pattern.language.as_ref(), pattern.combined) { - if let Some(language) = language_registry + if let (Some(language_name), true) = (pattern.language.as_ref(), pattern.combined) + && let Some(language) = language_registry .language_for_name_or_extension(language_name) .now_or_never() .and_then(|language| language.ok()) { combined_injection_ranges.insert(language.id, (language, Vec::new())); } - } } for query_range in changed_ranges { @@ -1357,11 +1353,10 @@ fn get_injections( content_ranges.first().unwrap().start_byte..content_ranges.last().unwrap().end_byte; // Avoid duplicate matches if two changed ranges intersect the same injection. - if let Some((prev_pattern_ix, prev_range)) = &prev_match { - if mat.pattern_index == *prev_pattern_ix && content_range == *prev_range { + if let Some((prev_pattern_ix, prev_range)) = &prev_match + && mat.pattern_index == *prev_pattern_ix && content_range == *prev_range { continue; } - } prev_match = Some((mat.pattern_index, content_range.clone())); let combined = config.patterns[mat.pattern_index].combined; diff --git a/crates/language/src/text_diff.rs b/crates/language/src/text_diff.rs index af8ce60881..18bf38f819 100644 --- a/crates/language/src/text_diff.rs +++ b/crates/language/src/text_diff.rs @@ -189,12 +189,11 @@ fn tokenize(text: &str, language_scope: Option) -> impl Iterator< while let Some((ix, c)) = chars.next() { let mut token = None; let kind = classifier.kind(c); - if let Some((prev_char, prev_kind)) = prev { - if kind != prev_kind || (kind == CharKind::Punctuation && c != prev_char) { + if let Some((prev_char, prev_kind)) = prev + && (kind != prev_kind || (kind == CharKind::Punctuation && c != prev_char)) { token = Some(&text[start_ix..ix]); start_ix = ix; } - } prev = Some((c, kind)); if token.is_some() { return token; diff --git a/crates/language_model/src/request.rs b/crates/language_model/src/request.rs index 8c2d169973..47858620ef 100644 --- a/crates/language_model/src/request.rs +++ b/crates/language_model/src/request.rs @@ -221,38 +221,31 @@ impl<'de> Deserialize<'de> for LanguageModelToolResultContent { // Accept wrapped text format: { "type": "text", "text": "..." } if let (Some(type_value), Some(text_value)) = (get_field(obj, "type"), get_field(obj, "text")) - { - if let Some(type_str) = type_value.as_str() { - if type_str.to_lowercase() == "text" { - if let Some(text) = text_value.as_str() { + && let Some(type_str) = type_value.as_str() + && type_str.to_lowercase() == "text" + && let Some(text) = text_value.as_str() { return Ok(Self::Text(Arc::from(text))); } - } - } - } // Check for wrapped Text variant: { "text": "..." } - if let Some((_key, value)) = obj.iter().find(|(k, _)| k.to_lowercase() == "text") { - if obj.len() == 1 { + if let Some((_key, value)) = obj.iter().find(|(k, _)| k.to_lowercase() == "text") + && obj.len() == 1 { // Only one field, and it's "text" (case-insensitive) if let Some(text) = value.as_str() { return Ok(Self::Text(Arc::from(text))); } } - } // Check for wrapped Image variant: { "image": { "source": "...", "size": ... } } - if let Some((_key, value)) = obj.iter().find(|(k, _)| k.to_lowercase() == "image") { - if obj.len() == 1 { + if let Some((_key, value)) = obj.iter().find(|(k, _)| k.to_lowercase() == "image") + && obj.len() == 1 { // Only one field, and it's "image" (case-insensitive) // Try to parse the nested image object - if let Some(image_obj) = value.as_object() { - if let Some(image) = LanguageModelImage::from_json(image_obj) { + if let Some(image_obj) = value.as_object() + && let Some(image) = LanguageModelImage::from_json(image_obj) { return Ok(Self::Image(image)); } - } } - } // Try as direct Image (object with "source" and "size" fields) if let Some(image) = LanguageModelImage::from_json(obj) { diff --git a/crates/language_models/src/provider/anthropic.rs b/crates/language_models/src/provider/anthropic.rs index 7ba56ec775..3aacd5cc71 100644 --- a/crates/language_models/src/provider/anthropic.rs +++ b/crates/language_models/src/provider/anthropic.rs @@ -633,12 +633,11 @@ pub fn into_anthropic( Role::Assistant => anthropic::Role::Assistant, Role::System => unreachable!("System role should never occur here"), }; - if let Some(last_message) = new_messages.last_mut() { - if last_message.role == anthropic_role { + if let Some(last_message) = new_messages.last_mut() + && last_message.role == anthropic_role { last_message.content.extend(anthropic_message_content); continue; } - } // Mark the last segment of the message as cached if message.cache { diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rs index f33a00972d..7a84b78b33 100644 --- a/crates/language_models/src/provider/bedrock.rs +++ b/crates/language_models/src/provider/bedrock.rs @@ -412,11 +412,10 @@ impl BedrockModel { .region(Region::new(region)) .timeout_config(TimeoutConfig::disabled()); - if let Some(endpoint_url) = endpoint { - if !endpoint_url.is_empty() { + if let Some(endpoint_url) = endpoint + && !endpoint_url.is_empty() { config_builder = config_builder.endpoint_url(endpoint_url); } - } match auth_method { None => { @@ -728,12 +727,11 @@ pub fn into_bedrock( Role::Assistant => bedrock::BedrockRole::Assistant, Role::System => unreachable!("System role should never occur here"), }; - if let Some(last_message) = new_messages.last_mut() { - if last_message.role == bedrock_role { + if let Some(last_message) = new_messages.last_mut() + && last_message.role == bedrock_role { last_message.content.extend(bedrock_message_content); continue; } - } new_messages.push( BedrockMessage::builder() .role(bedrock_role) diff --git a/crates/language_models/src/provider/cloud.rs b/crates/language_models/src/provider/cloud.rs index f226d0c6a8..c627167acb 100644 --- a/crates/language_models/src/provider/cloud.rs +++ b/crates/language_models/src/provider/cloud.rs @@ -597,8 +597,7 @@ impl CloudLanguageModel { .headers() .get(SUBSCRIPTION_LIMIT_RESOURCE_HEADER_NAME) .and_then(|resource| resource.to_str().ok()) - { - if let Some(plan) = response + && let Some(plan) = response .headers() .get(CURRENT_PLAN_HEADER_NAME) .and_then(|plan| plan.to_str().ok()) @@ -606,7 +605,6 @@ impl CloudLanguageModel { { return Err(anyhow!(ModelRequestLimitReachedError { plan })); } - } } else if status == StatusCode::PAYMENT_REQUIRED { return Err(anyhow!(PaymentRequiredError)); } @@ -662,8 +660,8 @@ where impl From for LanguageModelCompletionError { fn from(error: ApiError) -> Self { - if let Ok(cloud_error) = serde_json::from_str::(&error.body) { - if cloud_error.code.starts_with("upstream_http_") { + if let Ok(cloud_error) = serde_json::from_str::(&error.body) + && cloud_error.code.starts_with("upstream_http_") { let status = if let Some(status) = cloud_error.upstream_status { status } else if cloud_error.code.ends_with("_error") { @@ -685,7 +683,6 @@ impl From for LanguageModelCompletionError { retry_after: cloud_error.retry_after.map(Duration::from_secs_f64), }; } - } let retry_after = None; LanguageModelCompletionError::from_http_status( diff --git a/crates/language_selector/src/active_buffer_language.rs b/crates/language_selector/src/active_buffer_language.rs index c5c5eceab5..a605932300 100644 --- a/crates/language_selector/src/active_buffer_language.rs +++ b/crates/language_selector/src/active_buffer_language.rs @@ -28,11 +28,10 @@ impl ActiveBufferLanguage { self.active_language = Some(None); let editor = editor.read(cx); - if let Some((_, buffer, _)) = editor.active_excerpt(cx) { - if let Some(language) = buffer.read(cx).language() { + if let Some((_, buffer, _)) = editor.active_excerpt(cx) + && let Some(language) = buffer.read(cx).language() { self.active_language = Some(Some(language.name())); } - } cx.notify(); } diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rs index c303a8c305..a54a97362c 100644 --- a/crates/language_tools/src/lsp_log.rs +++ b/crates/language_tools/src/lsp_log.rs @@ -254,8 +254,8 @@ impl LogStore { let copilot_subscription = Copilot::global(cx).map(|copilot| { let copilot = &copilot; cx.subscribe(copilot, |this, copilot, edit_prediction_event, cx| { - if let copilot::Event::CopilotLanguageServerStarted = edit_prediction_event { - if let Some(server) = copilot.read(cx).language_server() { + if let copilot::Event::CopilotLanguageServerStarted = edit_prediction_event + && let Some(server) = copilot.read(cx).language_server() { let server_id = server.server_id(); let weak_this = cx.weak_entity(); this.copilot_log_subscription = @@ -283,7 +283,6 @@ impl LogStore { cx, ); } - } }) }); @@ -733,8 +732,8 @@ impl LspLogView { let first_server_id_for_project = store.read(cx).server_ids_for_project(&weak_project).next(); if let Some(current_lsp) = this.current_server_id { - if !store.read(cx).language_servers.contains_key(¤t_lsp) { - if let Some(server_id) = first_server_id_for_project { + if !store.read(cx).language_servers.contains_key(¤t_lsp) + && let Some(server_id) = first_server_id_for_project { match this.active_entry_kind { LogKind::Rpc => { this.show_rpc_trace_for_server(server_id, window, cx) @@ -744,7 +743,6 @@ impl LspLogView { LogKind::ServerInfo => this.show_server_info(server_id, window, cx), } } - } } else if let Some(server_id) = first_server_id_for_project { match this.active_entry_kind { LogKind::Rpc => this.show_rpc_trace_for_server(server_id, window, cx), @@ -776,11 +774,10 @@ impl LspLogView { ], cx, ); - if text.len() > 1024 { - if let Some((fold_offset, _)) = + if text.len() > 1024 + && let Some((fold_offset, _)) = text.char_indices().dropping(1024).next() - { - if fold_offset < text.len() { + && fold_offset < text.len() { editor.fold_ranges( vec![ last_offset + fold_offset..last_offset + text.len(), @@ -790,8 +787,6 @@ impl LspLogView { cx, ); } - } - } if newest_cursor_is_at_end { editor.request_autoscroll(Autoscroll::bottom(), cx); @@ -1311,15 +1306,14 @@ impl ToolbarItemView for LspLogToolbarItemView { _: &mut Window, cx: &mut Context, ) -> workspace::ToolbarItemLocation { - if let Some(item) = active_pane_item { - if let Some(log_view) = item.downcast::() { + if let Some(item) = active_pane_item + && let Some(log_view) = item.downcast::() { self.log_view = Some(log_view.clone()); self._log_view_subscription = Some(cx.observe(&log_view, |_, _, cx| { cx.notify(); })); return ToolbarItemLocation::PrimaryLeft; } - } self.log_view = None; self._log_view_subscription = None; ToolbarItemLocation::Hidden diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index 9946442ec8..1ae0f491c3 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -103,13 +103,11 @@ impl SyntaxTreeView { window: &mut Window, cx: &mut Context, ) { - if let Some(item) = active_item { - if item.item_id() != cx.entity_id() { - if let Some(editor) = item.act_as::(cx) { + if let Some(item) = active_item + && item.item_id() != cx.entity_id() + && let Some(editor) = item.act_as::(cx) { self.set_editor(editor, window, cx); } - } - } } fn set_editor(&mut self, editor: Entity, window: &mut Window, cx: &mut Context) { @@ -537,13 +535,12 @@ impl ToolbarItemView for SyntaxTreeToolbarItemView { window: &mut Window, cx: &mut Context, ) -> ToolbarItemLocation { - if let Some(item) = active_pane_item { - if let Some(view) = item.downcast::() { + if let Some(item) = active_pane_item + && let Some(view) = item.downcast::() { self.tree_view = Some(view.clone()); self.subscription = Some(cx.observe_in(&view, window, |_, _, _, cx| cx.notify())); return ToolbarItemLocation::PrimaryLeft; } - } self.tree_view = None; self.subscription = None; ToolbarItemLocation::Hidden diff --git a/crates/languages/src/go.rs b/crates/languages/src/go.rs index f739c5c4c6..c20e4bc678 100644 --- a/crates/languages/src/go.rs +++ b/crates/languages/src/go.rs @@ -131,8 +131,8 @@ impl super::LspAdapter for GoLspAdapter { if let Some(version) = *version { let binary_path = container_dir.join(format!("gopls_{version}_go_{go_version}")); - if let Ok(metadata) = fs::metadata(&binary_path).await { - if metadata.is_file() { + if let Ok(metadata) = fs::metadata(&binary_path).await + && metadata.is_file() { remove_matching(&container_dir, |entry| { entry != binary_path && entry.file_name() != Some(OsStr::new("gobin")) }) @@ -144,7 +144,6 @@ impl super::LspAdapter for GoLspAdapter { env: None, }); } - } } else if let Some(path) = this .cached_server_binary(container_dir.clone(), delegate) .await diff --git a/crates/languages/src/lib.rs b/crates/languages/src/lib.rs index e446f22713..a462a39813 100644 --- a/crates/languages/src/lib.rs +++ b/crates/languages/src/lib.rs @@ -244,12 +244,11 @@ pub fn init(languages: Arc, node: NodeRuntime, cx: &mut App) { cx.observe_flag::({ let languages = languages.clone(); move |enabled, _| { - if enabled { - if let Some(adapter) = basedpyright_lsp_adapter.take() { + if enabled + && let Some(adapter) = basedpyright_lsp_adapter.take() { languages .register_available_lsp_adapter(adapter.name(), move || adapter.clone()); } - } } }) .detach(); diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index 17d0d98fad..0ad173ec2f 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -338,8 +338,8 @@ impl LspAdapter for PythonLspAdapter { let interpreter_path = toolchain.path.to_string(); // Detect if this is a virtual environment - if let Some(interpreter_dir) = Path::new(&interpreter_path).parent() { - if let Some(venv_dir) = interpreter_dir.parent() { + if let Some(interpreter_dir) = Path::new(&interpreter_path).parent() + && let Some(venv_dir) = interpreter_dir.parent() { // Check if this looks like a virtual environment if venv_dir.join("pyvenv.cfg").exists() || venv_dir.join("bin/activate").exists() @@ -365,7 +365,6 @@ impl LspAdapter for PythonLspAdapter { } } } - } // Always set the python interpreter path // Get or create the python section @@ -1519,8 +1518,8 @@ impl LspAdapter for BasedPyrightLspAdapter { let interpreter_path = toolchain.path.to_string(); // Detect if this is a virtual environment - if let Some(interpreter_dir) = Path::new(&interpreter_path).parent() { - if let Some(venv_dir) = interpreter_dir.parent() { + if let Some(interpreter_dir) = Path::new(&interpreter_path).parent() + && let Some(venv_dir) = interpreter_dir.parent() { // Check if this looks like a virtual environment if venv_dir.join("pyvenv.cfg").exists() || venv_dir.join("bin/activate").exists() @@ -1546,7 +1545,6 @@ impl LspAdapter for BasedPyrightLspAdapter { } } } - } // Always set the python interpreter path // Get or create the python section diff --git a/crates/languages/src/rust.rs b/crates/languages/src/rust.rs index bbdfcdb499..8b2489ecc3 100644 --- a/crates/languages/src/rust.rs +++ b/crates/languages/src/rust.rs @@ -598,13 +598,11 @@ impl ContextProvider for RustContextProvider { if let Some(path) = local_abs_path .as_deref() .and_then(|local_abs_path| local_abs_path.parent()) - { - if let Some(package_name) = + && let Some(package_name) = human_readable_package_name(path, project_env.as_ref()).await { variables.insert(RUST_PACKAGE_TASK_VARIABLE.clone(), package_name); } - } if let Some(path) = local_abs_path.as_ref() && let Some((target, manifest_path)) = target_info_from_abs_path(path, project_env.as_ref()).await diff --git a/crates/languages/src/typescript.rs b/crates/languages/src/typescript.rs index 7937adbc09..88345329cb 100644 --- a/crates/languages/src/typescript.rs +++ b/crates/languages/src/typescript.rs @@ -341,11 +341,10 @@ async fn detect_package_manager( fs: Arc, package_json_data: Option, ) -> &'static str { - if let Some(package_json_data) = package_json_data { - if let Some(package_manager) = package_json_data.package_manager { + if let Some(package_json_data) = package_json_data + && let Some(package_manager) = package_json_data.package_manager { return package_manager; } - } if fs.is_file(&worktree_root.join("pnpm-lock.yaml")).await { return "pnpm"; } diff --git a/crates/livekit_client/src/test.rs b/crates/livekit_client/src/test.rs index e0058d1163..cd22632afb 100644 --- a/crates/livekit_client/src/test.rs +++ b/crates/livekit_client/src/test.rs @@ -736,15 +736,14 @@ impl Room { impl Drop for RoomState { fn drop(&mut self) { - if self.connection_state == ConnectionState::Connected { - if let Ok(server) = TestServer::get(&self.url) { + if self.connection_state == ConnectionState::Connected + && let Ok(server) = TestServer::get(&self.url) { let executor = server.executor.clone(); let token = self.token.clone(); executor .spawn(async move { server.leave_room(token).await.ok() }) .detach(); } - } } } diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index e5709bc07c..68efbff91c 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -340,8 +340,8 @@ impl Markdown { } for (range, event) in &events { - if let MarkdownEvent::Start(MarkdownTag::Image { dest_url, .. }) = event { - if let Some(data_url) = dest_url.strip_prefix("data:") { + if let MarkdownEvent::Start(MarkdownTag::Image { dest_url, .. }) = event + && let Some(data_url) = dest_url.strip_prefix("data:") { let Some((mime_info, data)) = data_url.split_once(',') else { continue; }; @@ -352,17 +352,15 @@ impl Markdown { continue; }; let is_base64 = encoding == "base64"; - if is_base64 { - if let Some(bytes) = base64::prelude::BASE64_STANDARD + if is_base64 + && let Some(bytes) = base64::prelude::BASE64_STANDARD .decode(data) .log_with_level(Level::Debug) { let image = Arc::new(Image::from_bytes(format, bytes)); images_by_source_offset.insert(range.start, image); } - } } - } } ( @@ -659,15 +657,14 @@ impl MarkdownElement { let rendered_text = rendered_text.clone(); move |markdown, event: &MouseUpEvent, phase, window, cx| { if phase.bubble() { - if let Some(pressed_link) = markdown.pressed_link.take() { - if Some(&pressed_link) == rendered_text.link_for_position(event.position) { + if let Some(pressed_link) = markdown.pressed_link.take() + && Some(&pressed_link) == rendered_text.link_for_position(event.position) { if let Some(open_url) = on_open_url.as_ref() { open_url(pressed_link.destination_url, window, cx); } else { cx.open_url(&pressed_link.destination_url); } } - } } else if markdown.selection.pending { markdown.selection.pending = false; #[cfg(any(target_os = "linux", target_os = "freebsd"))] @@ -758,11 +755,10 @@ impl Element for MarkdownElement { let mut current_img_block_range: Option> = None; for (range, event) in parsed_markdown.events.iter() { // Skip alt text for images that rendered - if let Some(current_img_block_range) = ¤t_img_block_range { - if current_img_block_range.end > range.end { + if let Some(current_img_block_range) = ¤t_img_block_range + && current_img_block_range.end > range.end { continue; } - } match event { MarkdownEvent::Start(tag) => { @@ -1696,11 +1692,10 @@ impl RenderedText { while let Some(line) = lines.next() { let line_bounds = line.layout.bounds(); if position.y > line_bounds.bottom() { - if let Some(next_line) = lines.peek() { - if position.y < next_line.layout.bounds().top() { + if let Some(next_line) = lines.peek() + && position.y < next_line.layout.bounds().top() { return Err(line.source_end); } - } continue; } diff --git a/crates/markdown_preview/src/markdown_parser.rs b/crates/markdown_preview/src/markdown_parser.rs index 27691f2ecf..ce6f1e55e0 100644 --- a/crates/markdown_preview/src/markdown_parser.rs +++ b/crates/markdown_preview/src/markdown_parser.rs @@ -300,14 +300,13 @@ impl<'a> MarkdownParser<'a> { if style != MarkdownHighlightStyle::default() && last_run_len < text.len() { let mut new_highlight = true; - if let Some((last_range, last_style)) = highlights.last_mut() { - if last_range.end == last_run_len + if let Some((last_range, last_style)) = highlights.last_mut() + && last_range.end == last_run_len && last_style == &MarkdownHighlight::Style(style.clone()) { last_range.end = text.len(); new_highlight = false; } - } if new_highlight { highlights.push(( last_run_len..text.len(), @@ -579,11 +578,10 @@ impl<'a> MarkdownParser<'a> { } } else { let block = self.parse_block().await; - if let Some(block) = block { - if let Some(list_item) = items_stack.last_mut() { + if let Some(block) = block + && let Some(list_item) = items_stack.last_mut() { list_item.content.extend(block); } - } } } diff --git a/crates/markdown_preview/src/markdown_preview_view.rs b/crates/markdown_preview/src/markdown_preview_view.rs index a0c8819991..d71aad28ab 100644 --- a/crates/markdown_preview/src/markdown_preview_view.rs +++ b/crates/markdown_preview/src/markdown_preview_view.rs @@ -151,11 +151,9 @@ impl MarkdownPreviewView { if let Some(editor) = workspace .active_item(cx) .and_then(|item| item.act_as::(cx)) - { - if Self::is_markdown_file(&editor, cx) { + && Self::is_markdown_file(&editor, cx) { return Some(editor); } - } None } @@ -243,33 +241,28 @@ impl MarkdownPreviewView { window: &mut Window, cx: &mut Context, ) { - if let Some(item) = active_item { - if item.item_id() != cx.entity_id() { - if let Some(editor) = item.act_as::(cx) { - if Self::is_markdown_file(&editor, cx) { + if let Some(item) = active_item + && item.item_id() != cx.entity_id() + && let Some(editor) = item.act_as::(cx) + && Self::is_markdown_file(&editor, cx) { self.set_editor(editor, window, cx); } - } - } - } } pub fn is_markdown_file(editor: &Entity, cx: &mut Context) -> bool { let buffer = editor.read(cx).buffer().read(cx); - if let Some(buffer) = buffer.as_singleton() { - if let Some(language) = buffer.read(cx).language() { + if let Some(buffer) = buffer.as_singleton() + && let Some(language) = buffer.read(cx).language() { return language.name() == "Markdown".into(); } - } false } fn set_editor(&mut self, editor: Entity, window: &mut Window, cx: &mut Context) { - if let Some(active) = &self.active_editor { - if active.editor == editor { + if let Some(active) = &self.active_editor + && active.editor == editor { return; } - } let subscription = cx.subscribe_in( &editor, @@ -552,8 +545,8 @@ impl Render for MarkdownPreviewView { .group("markdown-block") .on_click(cx.listener( move |this, event: &ClickEvent, window, cx| { - if event.click_count() == 2 { - if let Some(source_range) = this + if event.click_count() == 2 + && let Some(source_range) = this .contents .as_ref() .and_then(|c| c.children.get(ix)) @@ -567,7 +560,6 @@ impl Render for MarkdownPreviewView { source_range.start..source_range.start, ); } - } }, )) .map(move |container| { diff --git a/crates/migrator/src/migrations/m_2025_06_16/settings.rs b/crates/migrator/src/migrations/m_2025_06_16/settings.rs index cce407e21b..ff3f20af4b 100644 --- a/crates/migrator/src/migrations/m_2025_06_16/settings.rs +++ b/crates/migrator/src/migrations/m_2025_06_16/settings.rs @@ -40,8 +40,8 @@ fn migrate_context_server_settings( // Parse the server settings to check what keys it contains let mut cursor = server_settings.walk(); for child in server_settings.children(&mut cursor) { - if child.kind() == "pair" { - if let Some(key_node) = child.child_by_field_name("key") { + if child.kind() == "pair" + && let Some(key_node) = child.child_by_field_name("key") { if let (None, Some(quote_content)) = (column, key_node.child(0)) { column = Some(quote_content.start_position().column); } @@ -56,7 +56,6 @@ fn migrate_context_server_settings( } } } - } } let source_type = if has_command { "custom" } else { "extension" }; diff --git a/crates/migrator/src/migrations/m_2025_06_25/settings.rs b/crates/migrator/src/migrations/m_2025_06_25/settings.rs index 5dd6c3093a..40d446eb61 100644 --- a/crates/migrator/src/migrations/m_2025_06_25/settings.rs +++ b/crates/migrator/src/migrations/m_2025_06_25/settings.rs @@ -84,11 +84,10 @@ fn remove_pair_with_whitespace( } } else { // If no next sibling, check if there's a comma before - if let Some(prev_sibling) = pair_node.prev_sibling() { - if prev_sibling.kind() == "," { + if let Some(prev_sibling) = pair_node.prev_sibling() + && prev_sibling.kind() == "," { range_to_remove.start = prev_sibling.start_byte(); } - } } // Include any leading whitespace/newline, including comments @@ -123,11 +122,10 @@ fn remove_pair_with_whitespace( // Also check if we need to include trailing whitespace up to the next line let text_after = &contents[range_to_remove.end..]; - if let Some(newline_pos) = text_after.find('\n') { - if text_after[..newline_pos].chars().all(|c| c.is_whitespace()) { + if let Some(newline_pos) = text_after.find('\n') + && text_after[..newline_pos].chars().all(|c| c.is_whitespace()) { range_to_remove.end += newline_pos + 1; } - } Some((range_to_remove, String::new())) } diff --git a/crates/migrator/src/migrations/m_2025_06_27/settings.rs b/crates/migrator/src/migrations/m_2025_06_27/settings.rs index 6156308fce..ef604148d9 100644 --- a/crates/migrator/src/migrations/m_2025_06_27/settings.rs +++ b/crates/migrator/src/migrations/m_2025_06_27/settings.rs @@ -56,9 +56,9 @@ fn flatten_context_server_command( let mut cursor = command_object.walk(); for child in command_object.children(&mut cursor) { - if child.kind() == "pair" { - if let Some(key_node) = child.child_by_field_name("key") { - if let Some(string_content) = key_node.child(1) { + if child.kind() == "pair" + && let Some(key_node) = child.child_by_field_name("key") + && let Some(string_content) = key_node.child(1) { let key = &contents[string_content.byte_range()]; if let Some(value_node) = child.child_by_field_name("value") { let value_range = value_node.byte_range(); @@ -70,8 +70,6 @@ fn flatten_context_server_command( } } } - } - } } let path = path_value?; diff --git a/crates/multi_buffer/src/anchor.rs b/crates/multi_buffer/src/anchor.rs index 8584519d56..ca077dba4a 100644 --- a/crates/multi_buffer/src/anchor.rs +++ b/crates/multi_buffer/src/anchor.rs @@ -76,8 +76,8 @@ impl Anchor { if text_cmp.is_ne() { return text_cmp; } - if self.diff_base_anchor.is_some() || other.diff_base_anchor.is_some() { - if let Some(base_text) = snapshot + if (self.diff_base_anchor.is_some() || other.diff_base_anchor.is_some()) + && let Some(base_text) = snapshot .diffs .get(&excerpt.buffer_id) .map(|diff| diff.base_text()) @@ -97,7 +97,6 @@ impl Anchor { (None, None) => Ordering::Equal, }; } - } } Ordering::Equal } @@ -107,8 +106,8 @@ impl Anchor { } pub fn bias_left(&self, snapshot: &MultiBufferSnapshot) -> Anchor { - if self.text_anchor.bias != Bias::Left { - if let Some(excerpt) = snapshot.excerpt(self.excerpt_id) { + if self.text_anchor.bias != Bias::Left + && let Some(excerpt) = snapshot.excerpt(self.excerpt_id) { return Self { buffer_id: self.buffer_id, excerpt_id: self.excerpt_id, @@ -118,22 +117,19 @@ impl Anchor { .diffs .get(&excerpt.buffer_id) .map(|diff| diff.base_text()) - { - if a.buffer_id == Some(base_text.remote_id()) { + && a.buffer_id == Some(base_text.remote_id()) { return a.bias_left(base_text); } - } a }), }; } - } *self } pub fn bias_right(&self, snapshot: &MultiBufferSnapshot) -> Anchor { - if self.text_anchor.bias != Bias::Right { - if let Some(excerpt) = snapshot.excerpt(self.excerpt_id) { + if self.text_anchor.bias != Bias::Right + && let Some(excerpt) = snapshot.excerpt(self.excerpt_id) { return Self { buffer_id: self.buffer_id, excerpt_id: self.excerpt_id, @@ -143,16 +139,13 @@ impl Anchor { .diffs .get(&excerpt.buffer_id) .map(|diff| diff.base_text()) - { - if a.buffer_id == Some(base_text.remote_id()) { + && a.buffer_id == Some(base_text.remote_id()) { return a.bias_right(base_text); } - } a }), }; } - } *self } diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 59eaa9934d..722070481a 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -1082,12 +1082,11 @@ impl MultiBuffer { let mut ranges: Vec> = Vec::new(); for edit in edits { - if let Some(last_range) = ranges.last_mut() { - if edit.range.start <= last_range.end { + if let Some(last_range) = ranges.last_mut() + && edit.range.start <= last_range.end { last_range.end = last_range.end.max(edit.range.end); continue; } - } ranges.push(edit.range); } @@ -1212,8 +1211,8 @@ impl MultiBuffer { for range in buffer.edited_ranges_for_transaction_id::(*buffer_transaction) { for excerpt_id in &buffer_state.excerpts { cursor.seek(excerpt_id, Bias::Left); - if let Some(excerpt) = cursor.item() { - if excerpt.locator == *excerpt_id { + if let Some(excerpt) = cursor.item() + && excerpt.locator == *excerpt_id { let excerpt_buffer_start = excerpt.range.context.start.summary::(buffer); let excerpt_buffer_end = excerpt.range.context.end.summary::(buffer); @@ -1232,7 +1231,6 @@ impl MultiBuffer { break; } } - } } } } @@ -1251,8 +1249,8 @@ impl MultiBuffer { buffer.update(cx, |buffer, _| { buffer.merge_transactions(transaction, destination) }); - } else if let Some(transaction) = self.history.forget(transaction) { - if let Some(destination) = self.history.transaction_mut(destination) { + } else if let Some(transaction) = self.history.forget(transaction) + && let Some(destination) = self.history.transaction_mut(destination) { for (buffer_id, buffer_transaction_id) in transaction.buffer_transactions { if let Some(destination_buffer_transaction_id) = destination.buffer_transactions.get(&buffer_id) @@ -1272,7 +1270,6 @@ impl MultiBuffer { } } } - } } pub fn finalize_last_transaction(&mut self, cx: &mut Context) { @@ -1562,12 +1559,11 @@ impl MultiBuffer { }); let mut merged_ranges: Vec> = Vec::new(); for range in expanded_ranges { - if let Some(last_range) = merged_ranges.last_mut() { - if last_range.context.end >= range.context.start { + if let Some(last_range) = merged_ranges.last_mut() + && last_range.context.end >= range.context.start { last_range.context.end = range.context.end; continue; } - } merged_ranges.push(range) } let Some(excerpt_id) = excerpt_ids.first() else { @@ -1794,16 +1790,15 @@ impl MultiBuffer { }; if let Some((last_id, last)) = to_insert.last_mut() { - if let Some(new) = new { - if last.context.end >= new.context.start { + if let Some(new) = new + && last.context.end >= new.context.start { last.context.end = last.context.end.max(new.context.end); excerpt_ids.push(*last_id); new_iter.next(); continue; } - } - if let Some((existing_id, existing_range)) = &existing { - if last.context.end >= existing_range.start { + if let Some((existing_id, existing_range)) = &existing + && last.context.end >= existing_range.start { last.context.end = last.context.end.max(existing_range.end); to_remove.push(*existing_id); self.snapshot @@ -1813,7 +1808,6 @@ impl MultiBuffer { existing_iter.next(); continue; } - } } match (new, existing) { @@ -2105,11 +2099,10 @@ impl MultiBuffer { .flatten() { cursor.seek_forward(&Some(locator), Bias::Left); - if let Some(excerpt) = cursor.item() { - if excerpt.locator == *locator { + if let Some(excerpt) = cursor.item() + && excerpt.locator == *locator { excerpts.push((excerpt.id, excerpt.range.clone())); } - } } excerpts @@ -2132,8 +2125,8 @@ impl MultiBuffer { let mut result = Vec::new(); for locator in locators { excerpts.seek_forward(&Some(locator), Bias::Left); - if let Some(excerpt) = excerpts.item() { - if excerpt.locator == *locator { + if let Some(excerpt) = excerpts.item() + && excerpt.locator == *locator { let excerpt_start = excerpts.start().1.clone(); let excerpt_end = ExcerptDimension(excerpt_start.0 + excerpt.text_summary.lines); @@ -2148,7 +2141,6 @@ impl MultiBuffer { result.push(start..end) } - } } result } @@ -2316,13 +2308,12 @@ impl MultiBuffer { // Skip over any subsequent excerpts that are also removed. if let Some(&next_excerpt_id) = excerpt_ids.peek() { let next_locator = snapshot.excerpt_locator_for_id(next_excerpt_id); - if let Some(next_excerpt) = cursor.item() { - if next_excerpt.locator == *next_locator { + if let Some(next_excerpt) = cursor.item() + && next_excerpt.locator == *next_locator { excerpt_ids.next(); excerpt = next_excerpt; continue 'remove_excerpts; } - } } break; @@ -2494,8 +2485,8 @@ impl MultiBuffer { .excerpts .cursor::, ExcerptOffset>>(&()); cursor.seek_forward(&Some(locator), Bias::Left); - if let Some(excerpt) = cursor.item() { - if excerpt.locator == *locator { + if let Some(excerpt) = cursor.item() + && excerpt.locator == *locator { let excerpt_buffer_range = excerpt.range.context.to_offset(&excerpt.buffer); if diff_change_range.end < excerpt_buffer_range.start || diff_change_range.start > excerpt_buffer_range.end @@ -2521,7 +2512,6 @@ impl MultiBuffer { new: edit_start..edit_end, }); } - } } self.sync_diff_transforms( @@ -3155,14 +3145,13 @@ impl MultiBuffer { at_transform_boundary = false; let transforms_before_edit = old_diff_transforms.slice(&edit.old.start, Bias::Left); self.append_diff_transforms(&mut new_diff_transforms, transforms_before_edit); - if let Some(transform) = old_diff_transforms.item() { - if old_diff_transforms.end().0 == edit.old.start + if let Some(transform) = old_diff_transforms.item() + && old_diff_transforms.end().0 == edit.old.start && old_diff_transforms.start().0 < edit.old.start { self.push_diff_transform(&mut new_diff_transforms, transform.clone()); old_diff_transforms.next(); } - } } // Compute the start of the edit in output coordinates. @@ -3431,8 +3420,7 @@ impl MultiBuffer { inserted_hunk_info, summary, }) = subtree.first() - { - if self.extend_last_buffer_content_transform( + && self.extend_last_buffer_content_transform( new_transforms, *inserted_hunk_info, *summary, @@ -3443,7 +3431,6 @@ impl MultiBuffer { new_transforms.append(cursor.suffix(), &()); return; } - } new_transforms.append(subtree, &()); } @@ -3456,15 +3443,13 @@ impl MultiBuffer { inserted_hunk_info: inserted_hunk_anchor, summary, } = transform - { - if self.extend_last_buffer_content_transform( + && self.extend_last_buffer_content_transform( new_transforms, inserted_hunk_anchor, summary, ) { return; } - } new_transforms.push(transform, &()); } @@ -3518,12 +3503,10 @@ impl MultiBuffer { summary, inserted_hunk_info: inserted_hunk_anchor, } = last_transform - { - if *inserted_hunk_anchor == new_inserted_hunk_info { + && *inserted_hunk_anchor == new_inserted_hunk_info { *summary += summary_to_add; did_extend = true; } - } }, &(), ); @@ -4037,11 +4020,10 @@ impl MultiBufferSnapshot { cursor.seek(&query_range.start); - if let Some(region) = cursor.region().filter(|region| !region.is_main_buffer) { - if region.range.start > D::zero(&()) { + if let Some(region) = cursor.region().filter(|region| !region.is_main_buffer) + && region.range.start > D::zero(&()) { cursor.prev() } - } iter::from_fn(move || { loop { @@ -4070,11 +4052,10 @@ impl MultiBufferSnapshot { buffer_start = cursor.main_buffer_position()?; }; let mut buffer_end = excerpt.range.context.end.summary::(&excerpt.buffer); - if let Some((end_excerpt_id, end_buffer_offset)) = range_end { - if excerpt.id == end_excerpt_id { + if let Some((end_excerpt_id, end_buffer_offset)) = range_end + && excerpt.id == end_excerpt_id { buffer_end = buffer_end.min(end_buffer_offset); } - } if let Some(iterator) = get_buffer_metadata(&excerpt.buffer, buffer_start..buffer_end) @@ -4144,11 +4125,10 @@ impl MultiBufferSnapshot { // When there are no more metadata items for this excerpt, move to the next excerpt. else { current_excerpt_metadata.take(); - if let Some((end_excerpt_id, _)) = range_end { - if excerpt.id == end_excerpt_id { + if let Some((end_excerpt_id, _)) = range_end + && excerpt.id == end_excerpt_id { return None; } - } cursor.next_excerpt(); } } @@ -4622,8 +4602,8 @@ impl MultiBufferSnapshot { pub fn indent_and_comment_for_line(&self, row: MultiBufferRow, cx: &App) -> String { let mut indent = self.indent_size_for_line(row).chars().collect::(); - if self.language_settings(cx).extend_comment_on_newline { - if let Some(language_scope) = self.language_scope_at(Point::new(row.0, 0)) { + if self.language_settings(cx).extend_comment_on_newline + && let Some(language_scope) = self.language_scope_at(Point::new(row.0, 0)) { let delimiters = language_scope.line_comment_prefixes(); for delimiter in delimiters { if *self @@ -4638,7 +4618,6 @@ impl MultiBufferSnapshot { } } } - } indent } @@ -4893,11 +4872,10 @@ impl MultiBufferSnapshot { base_text_byte_range, .. }) => { - if let Some(diff_base_anchor) = &anchor.diff_base_anchor { - if let Some(base_text) = + if let Some(diff_base_anchor) = &anchor.diff_base_anchor + && let Some(base_text) = self.diffs.get(buffer_id).map(|diff| diff.base_text()) - { - if base_text.can_resolve(diff_base_anchor) { + && base_text.can_resolve(diff_base_anchor) { let base_text_offset = diff_base_anchor.to_offset(base_text); if base_text_offset >= base_text_byte_range.start && base_text_offset <= base_text_byte_range.end @@ -4912,8 +4890,6 @@ impl MultiBufferSnapshot { continue; } } - } - } } _ => { if at_transform_end && anchor.diff_base_anchor.is_some() { @@ -4941,8 +4917,8 @@ impl MultiBufferSnapshot { } let mut position = cursor.start().1; - if let Some(excerpt) = cursor.item() { - if excerpt.id == anchor.excerpt_id { + if let Some(excerpt) = cursor.item() + && excerpt.id == anchor.excerpt_id { let excerpt_buffer_start = excerpt .buffer .offset_for_anchor(&excerpt.range.context.start); @@ -4956,7 +4932,6 @@ impl MultiBufferSnapshot { position.value += buffer_position - excerpt_buffer_start; } } - } position } @@ -5211,8 +5186,8 @@ impl MultiBufferSnapshot { .cursor::>(&()); diff_transforms.seek(&offset, Bias::Right); - if offset == diff_transforms.start().0 && bias == Bias::Left { - if let Some(prev_item) = diff_transforms.prev_item() { + if offset == diff_transforms.start().0 && bias == Bias::Left + && let Some(prev_item) = diff_transforms.prev_item() { match prev_item { DiffTransform::DeletedHunk { .. } => { diff_transforms.prev(); @@ -5220,7 +5195,6 @@ impl MultiBufferSnapshot { _ => {} } } - } let offset_in_transform = offset - diff_transforms.start().0; let mut excerpt_offset = diff_transforms.start().1; let mut diff_base_anchor = None; @@ -5296,8 +5270,8 @@ impl MultiBufferSnapshot { let locator = self.excerpt_locator_for_id(excerpt_id); let mut cursor = self.excerpts.cursor::>(&()); cursor.seek(locator, Bias::Left); - if let Some(excerpt) = cursor.item() { - if excerpt.id == excerpt_id { + if let Some(excerpt) = cursor.item() + && excerpt.id == excerpt_id { let text_anchor = excerpt.clip_anchor(text_anchor); drop(cursor); return Some(Anchor { @@ -5307,7 +5281,6 @@ impl MultiBufferSnapshot { diff_base_anchor: None, }); } - } None } @@ -5860,11 +5833,10 @@ impl MultiBufferSnapshot { let current_depth = indent_stack.len() as u32; // Avoid retrieving the language settings repeatedly for every buffer row. - if let Some((prev_buffer_id, _)) = &prev_settings { - if prev_buffer_id != &buffer.remote_id() { + if let Some((prev_buffer_id, _)) = &prev_settings + && prev_buffer_id != &buffer.remote_id() { prev_settings.take(); } - } let settings = &prev_settings .get_or_insert_with(|| { ( @@ -6192,11 +6164,10 @@ impl MultiBufferSnapshot { } else { let mut cursor = self.excerpt_ids.cursor::(&()); cursor.seek(&id, Bias::Left); - if let Some(entry) = cursor.item() { - if entry.id == id { + if let Some(entry) = cursor.item() + && entry.id == id { return &entry.locator; } - } panic!("invalid excerpt id {id:?}") } } @@ -6272,11 +6243,10 @@ impl MultiBufferSnapshot { pub fn buffer_range_for_excerpt(&self, excerpt_id: ExcerptId) -> Option> { let mut cursor = self.excerpts.cursor::>(&()); let locator = self.excerpt_locator_for_id(excerpt_id); - if cursor.seek(&Some(locator), Bias::Left) { - if let Some(excerpt) = cursor.item() { + if cursor.seek(&Some(locator), Bias::Left) + && let Some(excerpt) = cursor.item() { return Some(excerpt.range.context.clone()); } - } None } @@ -6284,11 +6254,10 @@ impl MultiBufferSnapshot { let mut cursor = self.excerpts.cursor::>(&()); let locator = self.excerpt_locator_for_id(excerpt_id); cursor.seek(&Some(locator), Bias::Left); - if let Some(excerpt) = cursor.item() { - if excerpt.id == excerpt_id { + if let Some(excerpt) = cursor.item() + && excerpt.id == excerpt_id { return Some(excerpt); } - } None } @@ -6446,14 +6415,12 @@ impl MultiBufferSnapshot { inserted_hunk_info: prev_inserted_hunk_info, .. }) = prev_transform - { - if *inserted_hunk_info == *prev_inserted_hunk_info { + && *inserted_hunk_info == *prev_inserted_hunk_info { panic!( "multiple adjacent buffer content transforms with is_inserted_hunk = {inserted_hunk_info:?}. transforms: {:+?}", self.diff_transforms.items(&()) ); } - } if summary.len == 0 && !self.is_empty() { panic!("empty buffer content transform"); } @@ -6552,15 +6519,13 @@ where self.excerpts.next(); } else if let Some(DiffTransform::DeletedHunk { hunk_info, .. }) = self.diff_transforms.item() - { - if self + && self .excerpts .item() .map_or(false, |excerpt| excerpt.id != hunk_info.excerpt_id) { self.excerpts.next(); } - } } } } @@ -7855,11 +7820,10 @@ impl io::Read for ReversedMultiBufferBytes<'_> { if len > 0 { self.range.end -= len; self.chunk = &self.chunk[..self.chunk.len() - len]; - if !self.range.is_empty() && self.chunk.is_empty() { - if let Some(chunk) = self.chunks.next() { + if !self.range.is_empty() && self.chunk.is_empty() + && let Some(chunk) = self.chunks.next() { self.chunk = chunk.as_bytes(); } - } } Ok(len) } diff --git a/crates/multi_buffer/src/multi_buffer_tests.rs b/crates/multi_buffer/src/multi_buffer_tests.rs index fefeddb4da..7d5b58ec76 100644 --- a/crates/multi_buffer/src/multi_buffer_tests.rs +++ b/crates/multi_buffer/src/multi_buffer_tests.rs @@ -3592,9 +3592,9 @@ fn assert_position_translation(snapshot: &MultiBufferSnapshot) { for (anchors, bias) in [(&left_anchors, Bias::Left), (&right_anchors, Bias::Right)] { for (ix, (offset, anchor)) in offsets.iter().zip(anchors).enumerate() { - if ix > 0 { - if *offset == 252 { - if offset > &offsets[ix - 1] { + if ix > 0 + && *offset == 252 + && offset > &offsets[ix - 1] { let prev_anchor = left_anchors[ix - 1]; assert!( anchor.cmp(&prev_anchor, snapshot).is_gt(), @@ -3609,8 +3609,6 @@ fn assert_position_translation(snapshot: &MultiBufferSnapshot) { offsets[ix], ); } - } - } } } diff --git a/crates/notifications/src/notification_store.rs b/crates/notifications/src/notification_store.rs index 29653748e4..56d9e8950f 100644 --- a/crates/notifications/src/notification_store.rs +++ b/crates/notifications/src/notification_store.rs @@ -138,11 +138,10 @@ impl NotificationStore { pub fn notification_for_id(&self, id: u64) -> Option<&NotificationEntry> { let mut cursor = self.notifications.cursor::(&()); cursor.seek(&NotificationId(id), Bias::Left); - if let Some(item) = cursor.item() { - if item.id == id { + if let Some(item) = cursor.item() + && item.id == id { return Some(item); } - } None } @@ -229,8 +228,8 @@ impl NotificationStore { mut cx: AsyncApp, ) -> Result<()> { this.update(&mut cx, |this, cx| { - if let Some(notification) = envelope.payload.notification { - if let Some(rpc::Notification::ChannelMessageMention { message_id, .. }) = + if let Some(notification) = envelope.payload.notification + && let Some(rpc::Notification::ChannelMessageMention { message_id, .. }) = Notification::from_proto(¬ification) { let fetch_message_task = this.channel_store.update(cx, |this, cx| { @@ -248,7 +247,6 @@ impl NotificationStore { }) .detach_and_log_err(cx) } - } Ok(()) })? } @@ -390,13 +388,12 @@ impl NotificationStore { }); } } - } else if let Some(new_notification) = &new_notification { - if is_new { + } else if let Some(new_notification) = &new_notification + && is_new { cx.emit(NotificationEvent::NewNotification { entry: new_notification.clone(), }); } - } if let Some(notification) = new_notification { new_notifications.push(notification, &()); diff --git a/crates/open_router/src/open_router.rs b/crates/open_router/src/open_router.rs index 3e6e406d98..d9f698e8a1 100644 --- a/crates/open_router/src/open_router.rs +++ b/crates/open_router/src/open_router.rs @@ -240,11 +240,10 @@ impl MessageContent { impl From> for MessageContent { fn from(parts: Vec) -> Self { - if parts.len() == 1 { - if let MessagePart::Text { text } = &parts[0] { + if parts.len() == 1 + && let MessagePart::Text { text } = &parts[0] { return Self::Plain(text.clone()); } - } Self::Multipart(parts) } } diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 9514fd7e36..ad016e8eda 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -1170,13 +1170,12 @@ impl OutlinePanel { }); } else { let mut offset = Point::default(); - if let Some(buffer_id) = scroll_to_buffer { - if multi_buffer_snapshot.as_singleton().is_none() + if let Some(buffer_id) = scroll_to_buffer + && multi_buffer_snapshot.as_singleton().is_none() && !active_editor.read(cx).is_buffer_folded(buffer_id, cx) { offset.y = -(active_editor.read(cx).file_header_size() as f32); } - } active_editor.update(cx, |editor, cx| { editor.set_scroll_anchor(ScrollAnchor { offset, anchor }, window, cx); @@ -1606,8 +1605,8 @@ impl OutlinePanel { } PanelEntry::FoldedDirs(folded_dirs) => { let mut folded = false; - if let Some(dir_entry) = folded_dirs.entries.last() { - if self + if let Some(dir_entry) = folded_dirs.entries.last() + && self .collapsed_entries .insert(CollapsedEntry::Dir(folded_dirs.worktree_id, dir_entry.id)) { @@ -1616,7 +1615,6 @@ impl OutlinePanel { self.buffers_inside_directory(folded_dirs.worktree_id, dir_entry), ); } - } folded } PanelEntry::Outline(OutlineEntry::Excerpt(excerpt)) => self @@ -2108,12 +2106,11 @@ impl OutlinePanel { dirs_to_expand.push(current_entry.id); } - if traversal.back_to_parent() { - if let Some(parent_entry) = traversal.entry() { + if traversal.back_to_parent() + && let Some(parent_entry) = traversal.entry() { current_entry = parent_entry.clone(); continue; } - } break; } } @@ -2475,8 +2472,8 @@ impl OutlinePanel { let search_data = match render_data.get() { Some(search_data) => search_data, None => { - if let ItemsDisplayMode::Search(search_state) = &mut self.mode { - if let Some(multi_buffer_snapshot) = multi_buffer_snapshot { + if let ItemsDisplayMode::Search(search_state) = &mut self.mode + && let Some(multi_buffer_snapshot) = multi_buffer_snapshot { search_state .highlight_search_match_tx .try_send(HighlightArguments { @@ -2486,7 +2483,6 @@ impl OutlinePanel { }) .ok(); } - } return None; } }; @@ -2833,12 +2829,11 @@ impl OutlinePanel { let new_entry_added = entries_to_add .insert(current_entry.id, current_entry) .is_none(); - if new_entry_added && traversal.back_to_parent() { - if let Some(parent_entry) = traversal.entry() { + if new_entry_added && traversal.back_to_parent() + && let Some(parent_entry) = traversal.entry() { current_entry = parent_entry.to_owned(); continue; } - } break; } new_worktree_entries @@ -2878,8 +2873,8 @@ impl OutlinePanel { entries .into_iter() .filter_map(|entry| { - if auto_fold_dirs { - if let Some(parent) = entry.path.parent() { + if auto_fold_dirs + && let Some(parent) = entry.path.parent() { let children = new_children_count .entry(worktree_id) .or_default() @@ -2891,7 +2886,6 @@ impl OutlinePanel { children.files += 1; } } - } if entry.is_dir() { Some(FsEntry::Directory(FsEntryDirectory { @@ -3409,8 +3403,8 @@ impl OutlinePanel { { excerpt.outlines = ExcerptOutlines::Outlines(fetched_outlines); - if let Some(default_depth) = pending_default_depth { - if let ExcerptOutlines::Outlines(outlines) = + if let Some(default_depth) = pending_default_depth + && let ExcerptOutlines::Outlines(outlines) = &excerpt.outlines { outlines @@ -3433,7 +3427,6 @@ impl OutlinePanel { ); }); } - } // Even if no outlines to check, we still need to update cached entries // to show the outline entries that were just fetched @@ -3611,10 +3604,9 @@ impl OutlinePanel { .update_in(cx, |outline_panel, window, cx| { outline_panel.cached_entries = new_cached_entries; outline_panel.max_width_item_index = max_width_item_index; - if outline_panel.selected_entry.is_invalidated() - || matches!(outline_panel.selected_entry, SelectedEntry::None) - { - if let Some(new_selected_entry) = + if (outline_panel.selected_entry.is_invalidated() + || matches!(outline_panel.selected_entry, SelectedEntry::None)) + && let Some(new_selected_entry) = outline_panel.active_editor().and_then(|active_editor| { outline_panel.location_for_editor_selection( &active_editor, @@ -3625,7 +3617,6 @@ impl OutlinePanel { { outline_panel.select_entry(new_selected_entry, false, window, cx); } - } outline_panel.autoscroll(cx); outline_panel.updating_cached_entries = false; @@ -3921,8 +3912,8 @@ impl OutlinePanel { } else { None }; - if let Some((buffer_id, entry_excerpts)) = excerpts_to_consider { - if !active_editor.read(cx).is_buffer_folded(buffer_id, cx) { + if let Some((buffer_id, entry_excerpts)) = excerpts_to_consider + && !active_editor.read(cx).is_buffer_folded(buffer_id, cx) { outline_panel.add_excerpt_entries( &mut generation_state, buffer_id, @@ -3934,7 +3925,6 @@ impl OutlinePanel { cx, ); } - } } } @@ -4404,16 +4394,14 @@ impl OutlinePanel { }) .filter(|(match_range, _)| { let editor = active_editor.read(cx); - if let Some(buffer_id) = match_range.start.buffer_id { - if editor.is_buffer_folded(buffer_id, cx) { + if let Some(buffer_id) = match_range.start.buffer_id + && editor.is_buffer_folded(buffer_id, cx) { return false; } - } - if let Some(buffer_id) = match_range.start.buffer_id { - if editor.is_buffer_folded(buffer_id, cx) { + if let Some(buffer_id) = match_range.start.buffer_id + && editor.is_buffer_folded(buffer_id, cx) { return false; } - } true }); @@ -4456,17 +4444,14 @@ impl OutlinePanel { cx: &mut Context, ) { self.pinned = !self.pinned; - if !self.pinned { - if let Some((active_item, active_editor)) = self + if !self.pinned + && let Some((active_item, active_editor)) = self .workspace .upgrade() .and_then(|workspace| workspace_active_editor(workspace.read(cx), cx)) - { - if self.should_replace_active_item(active_item.as_ref()) { + && self.should_replace_active_item(active_item.as_ref()) { self.replace_active_editor(active_item, active_editor, window, cx); } - } - } cx.notify(); } @@ -5067,8 +5052,8 @@ impl Panel for OutlinePanel { let old_active = outline_panel.active; outline_panel.active = active; if old_active != active { - if active { - if let Some((active_item, active_editor)) = + if active + && let Some((active_item, active_editor)) = outline_panel.workspace.upgrade().and_then(|workspace| { workspace_active_editor(workspace.read(cx), cx) }) @@ -5085,7 +5070,6 @@ impl Panel for OutlinePanel { } return; } - } if !outline_panel.pinned { outline_panel.clear_previous(window, cx); @@ -5319,8 +5303,8 @@ fn subscribe_for_editor_events( }) .copied(), ); - if !ignore_selections_change { - if let Some(entry_to_select) = latest_unfolded_buffer_id + if !ignore_selections_change + && let Some(entry_to_select) = latest_unfolded_buffer_id .or(latest_folded_buffer_id) .and_then(|toggled_buffer_id| { outline_panel.fs_entries.iter().find_map( @@ -5347,7 +5331,6 @@ fn subscribe_for_editor_events( { outline_panel.select_entry(entry_to_select, true, window, cx); } - } outline_panel.update_fs_entries(editor.clone(), debounce, window, cx); } diff --git a/crates/prettier/src/prettier.rs b/crates/prettier/src/prettier.rs index 33320e6845..c8f69f122e 100644 --- a/crates/prettier/src/prettier.rs +++ b/crates/prettier/src/prettier.rs @@ -185,12 +185,10 @@ impl Prettier { .metadata(&ignore_path) .await .with_context(|| format!("fetching metadata for {ignore_path:?}"))? - { - if !metadata.is_dir && !metadata.is_symlink { + && !metadata.is_dir && !metadata.is_symlink { log::info!("Found prettier ignore at {ignore_path:?}"); return Ok(ControlFlow::Continue(Some(path_to_check))); } - } match &closest_package_json_path { None => closest_package_json_path = Some(path_to_check.clone()), Some(closest_package_json_path) => { @@ -223,14 +221,13 @@ impl Prettier { }) { let workspace_ignore = path_to_check.join(".prettierignore"); - if let Some(metadata) = fs.metadata(&workspace_ignore).await? { - if !metadata.is_dir { + if let Some(metadata) = fs.metadata(&workspace_ignore).await? + && !metadata.is_dir { log::info!( "Found prettier ignore at workspace root {workspace_ignore:?}" ); return Ok(ControlFlow::Continue(Some(path_to_check))); } - } } } } @@ -549,8 +546,7 @@ async fn read_package_json( .metadata(&possible_package_json) .await .with_context(|| format!("fetching metadata for package json {possible_package_json:?}"))? - { - if !package_json_metadata.is_dir && !package_json_metadata.is_symlink { + && !package_json_metadata.is_dir && !package_json_metadata.is_symlink { let package_json_contents = fs .load(&possible_package_json) .await @@ -561,7 +557,6 @@ async fn read_package_json( .map(Some) .with_context(|| format!("parsing {possible_package_json:?} file contents")); } - } Ok(None) } diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rs index b8101e14f3..4ab0353548 100644 --- a/crates/project/src/buffer_store.rs +++ b/crates/project/src/buffer_store.rs @@ -1094,11 +1094,10 @@ impl BufferStore { .collect::>() })?; for buffer_task in buffers { - if let Some(buffer) = buffer_task.await.log_err() { - if tx.send(buffer).await.is_err() { + if let Some(buffer) = buffer_task.await.log_err() + && tx.send(buffer).await.is_err() { return anyhow::Ok(()); } - } } } anyhow::Ok(()) @@ -1173,12 +1172,11 @@ impl BufferStore { buffer_id: BufferId, handle: OpenLspBufferHandle, ) { - if let Some(shared_buffers) = self.shared_buffers.get_mut(&peer_id) { - if let Some(buffer) = shared_buffers.get_mut(&buffer_id) { + if let Some(shared_buffers) = self.shared_buffers.get_mut(&peer_id) + && let Some(buffer) = shared_buffers.get_mut(&buffer_id) { buffer.lsp_handle = Some(handle); return; } - } debug_panic!("tried to register shared lsp handle, but buffer was not shared") } @@ -1388,15 +1386,14 @@ impl BufferStore { let peer_id = envelope.sender_id; let buffer_id = BufferId::new(envelope.payload.buffer_id)?; this.update(&mut cx, |this, cx| { - if let Some(shared) = this.shared_buffers.get_mut(&peer_id) { - if shared.remove(&buffer_id).is_some() { + if let Some(shared) = this.shared_buffers.get_mut(&peer_id) + && shared.remove(&buffer_id).is_some() { cx.emit(BufferStoreEvent::SharedBufferClosed(peer_id, buffer_id)); if shared.is_empty() { this.shared_buffers.remove(&peer_id); } return; } - } debug_panic!( "peer_id {} closed buffer_id {} which was either not open or already closed", peer_id, diff --git a/crates/project/src/debugger/breakpoint_store.rs b/crates/project/src/debugger/breakpoint_store.rs index 091189db7c..c85ab43106 100644 --- a/crates/project/src/debugger/breakpoint_store.rs +++ b/crates/project/src/debugger/breakpoint_store.rs @@ -623,13 +623,12 @@ impl BreakpointStore { file_breakpoints.breakpoints.iter().filter_map({ let range = range.clone(); move |bp| { - if let Some(range) = &range { - if bp.position().cmp(&range.start, buffer_snapshot).is_lt() - || bp.position().cmp(&range.end, buffer_snapshot).is_gt() + if let Some(range) = &range + && (bp.position().cmp(&range.start, buffer_snapshot).is_lt() + || bp.position().cmp(&range.end, buffer_snapshot).is_gt()) { return None; } - } let session_state = active_session_id .and_then(|id| bp.session_state.get(&id)) .copied(); diff --git a/crates/project/src/debugger/memory.rs b/crates/project/src/debugger/memory.rs index fec3c344c5..12bb963e1c 100644 --- a/crates/project/src/debugger/memory.rs +++ b/crates/project/src/debugger/memory.rs @@ -318,8 +318,7 @@ impl Iterator for MemoryIterator { return None; } if let Some((current_page_address, current_memory_chunk)) = self.current_known_page.as_mut() - { - if current_page_address.0 <= self.start { + && current_page_address.0 <= self.start { if let Some(next_cell) = current_memory_chunk.next() { self.start += 1; return Some(next_cell); @@ -327,7 +326,6 @@ impl Iterator for MemoryIterator { self.current_known_page.take(); } } - } if !self.fetch_next_page() { self.start += 1; return Some(MemoryCell(None)); diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 9539008530..57c257f61a 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -570,8 +570,8 @@ impl GitStore { cx: &mut Context, ) -> Task>> { let buffer_id = buffer.read(cx).remote_id(); - if let Some(diff_state) = self.diffs.get(&buffer_id) { - if let Some(unstaged_diff) = diff_state + if let Some(diff_state) = self.diffs.get(&buffer_id) + && let Some(unstaged_diff) = diff_state .read(cx) .unstaged_diff .as_ref() @@ -587,7 +587,6 @@ impl GitStore { } return Task::ready(Ok(unstaged_diff)); } - } let Some((repo, repo_path)) = self.repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx) @@ -627,8 +626,8 @@ impl GitStore { ) -> Task>> { let buffer_id = buffer.read(cx).remote_id(); - if let Some(diff_state) = self.diffs.get(&buffer_id) { - if let Some(uncommitted_diff) = diff_state + if let Some(diff_state) = self.diffs.get(&buffer_id) + && let Some(uncommitted_diff) = diff_state .read(cx) .uncommitted_diff .as_ref() @@ -644,7 +643,6 @@ impl GitStore { } return Task::ready(Ok(uncommitted_diff)); } - } let Some((repo, repo_path)) = self.repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx) @@ -764,8 +762,8 @@ impl GitStore { log::debug!("open conflict set"); let buffer_id = buffer.read(cx).remote_id(); - if let Some(git_state) = self.diffs.get(&buffer_id) { - if let Some(conflict_set) = git_state + if let Some(git_state) = self.diffs.get(&buffer_id) + && let Some(conflict_set) = git_state .read(cx) .conflict_set .as_ref() @@ -780,7 +778,6 @@ impl GitStore { return conflict_set; } - } let is_unmerged = self .repository_and_path_for_buffer_id(buffer_id, cx) @@ -1151,8 +1148,7 @@ impl GitStore { for (buffer_id, diff) in self.diffs.iter() { if let Some((buffer_repo, repo_path)) = self.repository_and_path_for_buffer_id(*buffer_id, cx) - { - if buffer_repo == repo { + && buffer_repo == repo { diff.update(cx, |diff, cx| { if let Some(conflict_set) = &diff.conflict_set { let conflict_status_changed = @@ -1174,7 +1170,6 @@ impl GitStore { }) .ok(); } - } } cx.emit(GitStoreEvent::RepositoryUpdated( id, @@ -2231,14 +2226,13 @@ impl GitStore { ) -> Result<()> { let buffer_id = BufferId::new(request.payload.buffer_id)?; this.update(&mut cx, |this, cx| { - if let Some(diff_state) = this.diffs.get_mut(&buffer_id) { - if let Some(buffer) = this.buffer_store.read(cx).get(buffer_id) { + if let Some(diff_state) = this.diffs.get_mut(&buffer_id) + && let Some(buffer) = this.buffer_store.read(cx).get(buffer_id) { let buffer = buffer.read(cx).text_snapshot(); diff_state.update(cx, |diff_state, cx| { diff_state.handle_base_texts_updated(buffer, request.payload, cx); }) } - } }) } @@ -3533,15 +3527,14 @@ impl Repository { let Some(project_path) = self.repo_path_to_project_path(path, cx) else { continue; }; - if let Some(buffer) = buffer_store.get_by_path(&project_path) { - if buffer + if let Some(buffer) = buffer_store.get_by_path(&project_path) + && buffer .read(cx) .file() .map_or(false, |file| file.disk_state().exists()) { save_futures.push(buffer_store.save_buffer(buffer, cx)); } - } } }) } @@ -3600,15 +3593,14 @@ impl Repository { let Some(project_path) = self.repo_path_to_project_path(path, cx) else { continue; }; - if let Some(buffer) = buffer_store.get_by_path(&project_path) { - if buffer + if let Some(buffer) = buffer_store.get_by_path(&project_path) + && buffer .read(cx) .file() .map_or(false, |file| file.disk_state().exists()) { save_futures.push(buffer_store.save_buffer(buffer, cx)); } - } } }) } @@ -4421,14 +4413,13 @@ impl Repository { } if let Some(job) = jobs.pop_front() { - if let Some(current_key) = &job.key { - if jobs + if let Some(current_key) = &job.key + && jobs .iter() .any(|other_job| other_job.key.as_ref() == Some(current_key)) { continue; } - } (job.job)(state.clone(), cx).await; } else if let Some(job) = job_rx.next().await { jobs.push_back(job); @@ -4459,14 +4450,13 @@ impl Repository { } if let Some(job) = jobs.pop_front() { - if let Some(current_key) = &job.key { - if jobs + if let Some(current_key) = &job.key + && jobs .iter() .any(|other_job| other_job.key.as_ref() == Some(current_key)) { continue; } - } (job.job)(state.clone(), cx).await; } else if let Some(job) = job_rx.next().await { jobs.push_back(job); @@ -4589,11 +4579,10 @@ impl Repository { for (repo_path, status) in &*statuses.entries { changed_paths.remove(repo_path); - if cursor.seek_forward(&PathTarget::Path(repo_path), Bias::Left) { - if cursor.item().is_some_and(|entry| entry.status == *status) { + if cursor.seek_forward(&PathTarget::Path(repo_path), Bias::Left) + && cursor.item().is_some_and(|entry| entry.status == *status) { continue; } - } changed_path_statuses.push(Edit::Insert(StatusEntry { repo_path: repo_path.clone(), diff --git a/crates/project/src/git_store/git_traversal.rs b/crates/project/src/git_store/git_traversal.rs index de5ff9b935..2321fdb83a 100644 --- a/crates/project/src/git_store/git_traversal.rs +++ b/crates/project/src/git_store/git_traversal.rs @@ -182,12 +182,11 @@ impl<'a> Iterator for ChildEntriesGitIter<'a> { type Item = GitEntryRef<'a>; fn next(&mut self) -> Option { - if let Some(item) = self.traversal.entry() { - if item.path.starts_with(self.parent_path) { + if let Some(item) = self.traversal.entry() + && item.path.starts_with(self.parent_path) { self.traversal.advance_to_sibling(); return Some(item); } - } None } } diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rs index d5c3cc424f..18aa6be8f1 100644 --- a/crates/project/src/lsp_command.rs +++ b/crates/project/src/lsp_command.rs @@ -2341,8 +2341,8 @@ impl LspCommand for GetCompletions { .zip(completion_edits) .map(|(mut lsp_completion, mut edit)| { LineEnding::normalize(&mut edit.new_text); - if lsp_completion.data.is_none() { - if let Some(default_data) = lsp_defaults + if lsp_completion.data.is_none() + && let Some(default_data) = lsp_defaults .as_ref() .and_then(|item_defaults| item_defaults.data.clone()) { @@ -2350,7 +2350,6 @@ impl LspCommand for GetCompletions { // so we do not insert the defaults here, but `data` is needed for resolving, so this is an exception. lsp_completion.data = Some(default_data); } - } CoreCompletion { replace_range: edit.replace_range, new_text: edit.new_text, @@ -2623,11 +2622,10 @@ impl LspCommand for GetCodeActions { .filter_map(|entry| { let (lsp_action, resolved) = match entry { lsp::CodeActionOrCommand::CodeAction(lsp_action) => { - if let Some(command) = lsp_action.command.as_ref() { - if !available_commands.contains(&command.command) { + if let Some(command) = lsp_action.command.as_ref() + && !available_commands.contains(&command.command) { return None; } - } (LspAction::Action(Box::new(lsp_action)), false) } lsp::CodeActionOrCommand::Command(command) => { @@ -2641,11 +2639,9 @@ impl LspCommand for GetCodeActions { if let Some((requested_kinds, kind)) = requested_kinds_set.as_ref().zip(lsp_action.action_kind()) - { - if !requested_kinds.contains(&kind) { + && !requested_kinds.contains(&kind) { return None; } - } Some(CodeAction { server_id, diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 1bc6770d4e..368d8418d7 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -701,11 +701,9 @@ impl LocalLspStore { async move { this.update(&mut cx, |this, _| { if let Some(status) = this.language_server_statuses.get_mut(&server_id) - { - if let lsp::NumberOrString::String(token) = params.token { + && let lsp::NumberOrString::String(token) = params.token { status.progress_tokens.insert(token); } - } })?; Ok(()) @@ -1015,11 +1013,10 @@ impl LocalLspStore { } } LanguageServerState::Starting { startup, .. } => { - if let Some(server) = startup.await { - if let Some(shutdown) = server.shutdown() { + if let Some(server) = startup.await + && let Some(shutdown) = server.shutdown() { shutdown.await; } - } } } Ok(()) @@ -2384,16 +2381,14 @@ impl LocalLspStore { return None; } if !only_register_servers.is_empty() { - if let Some(server_id) = server_node.server_id() { - if !only_register_servers.contains(&LanguageServerSelector::Id(server_id)) { + if let Some(server_id) = server_node.server_id() + && !only_register_servers.contains(&LanguageServerSelector::Id(server_id)) { return None; } - } - if let Some(name) = server_node.name() { - if !only_register_servers.contains(&LanguageServerSelector::Name(name)) { + if let Some(name) = server_node.name() + && !only_register_servers.contains(&LanguageServerSelector::Name(name)) { return None; } - } } let server_id = server_node.server_id_or_init(|disposition| { @@ -2410,11 +2405,10 @@ impl LocalLspStore { cx, ); - if let Some(state) = self.language_servers.get(&server_id) { - if let Ok(uri) = uri { + if let Some(state) = self.language_servers.get(&server_id) + && let Ok(uri) = uri { state.add_workspace_folder(uri); }; - } server_id }; @@ -3844,15 +3838,14 @@ impl LspStore { } BufferStoreEvent::BufferChangedFilePath { buffer, old_file } => { let buffer_id = buffer.read(cx).remote_id(); - if let Some(local) = self.as_local_mut() { - if let Some(old_file) = File::from_dyn(old_file.as_ref()) { + if let Some(local) = self.as_local_mut() + && let Some(old_file) = File::from_dyn(old_file.as_ref()) { local.reset_buffer(buffer, old_file, cx); if local.registered_buffers.contains_key(&buffer_id) { local.unregister_old_buffer_from_language_servers(buffer, old_file, cx); } } - } self.detect_language_for_buffer(buffer, cx); if let Some(local) = self.as_local_mut() { @@ -4201,15 +4194,13 @@ impl LspStore { if local .registered_buffers .contains_key(&buffer.read(cx).remote_id()) - { - if let Some(file_url) = + && let Some(file_url) = file_path_to_lsp_url(&f.abs_path(cx)).log_err() { local.unregister_buffer_from_language_servers( &buffer, &file_url, cx, ); } - } } } } @@ -4306,21 +4297,17 @@ impl LspStore { let buffer = buffer_entity.read(cx); let buffer_file = buffer.file().cloned(); let buffer_id = buffer.remote_id(); - if let Some(local_store) = self.as_local_mut() { - if local_store.registered_buffers.contains_key(&buffer_id) { - if let Some(abs_path) = + if let Some(local_store) = self.as_local_mut() + && local_store.registered_buffers.contains_key(&buffer_id) + && let Some(abs_path) = File::from_dyn(buffer_file.as_ref()).map(|file| file.abs_path(cx)) - { - if let Some(file_url) = file_path_to_lsp_url(&abs_path).log_err() { + && let Some(file_url) = file_path_to_lsp_url(&abs_path).log_err() { local_store.unregister_buffer_from_language_servers( buffer_entity, &file_url, cx, ); } - } - } - } buffer_entity.update(cx, |buffer, cx| { if buffer.language().map_or(true, |old_language| { !Arc::ptr_eq(old_language, &new_language) @@ -4336,22 +4323,21 @@ impl LspStore { let worktree_id = if let Some(file) = buffer_file { let worktree = file.worktree.clone(); - if let Some(local) = self.as_local_mut() { - if local.registered_buffers.contains_key(&buffer_id) { + if let Some(local) = self.as_local_mut() + && local.registered_buffers.contains_key(&buffer_id) { local.register_buffer_with_language_servers( buffer_entity, HashSet::default(), cx, ); } - } Some(worktree.read(cx).id()) } else { None }; - if settings.prettier.allowed { - if let Some(prettier_plugins) = prettier_store::prettier_plugins_for_language(&settings) + if settings.prettier.allowed + && let Some(prettier_plugins) = prettier_store::prettier_plugins_for_language(&settings) { let prettier_store = self.as_local().map(|s| s.prettier_store.clone()); if let Some(prettier_store) = prettier_store { @@ -4364,7 +4350,6 @@ impl LspStore { }) } } - } cx.emit(LspStoreEvent::LanguageDetected { buffer: buffer_entity.clone(), @@ -4381,8 +4366,8 @@ impl LspStore { } pub(crate) fn send_diagnostic_summaries(&self, worktree: &mut Worktree) { - if let Some((client, downstream_project_id)) = self.downstream_client.clone() { - if let Some(diangostic_summaries) = self.diagnostic_summaries.get(&worktree.id()) { + if let Some((client, downstream_project_id)) = self.downstream_client.clone() + && let Some(diangostic_summaries) = self.diagnostic_summaries.get(&worktree.id()) { let mut summaries = diangostic_summaries .into_iter() @@ -4402,7 +4387,6 @@ impl LspStore { .log_err(); } } - } } // TODO: remove MultiLspQuery: instead, the proto handler should pick appropriate server(s) @@ -4730,11 +4714,10 @@ impl LspStore { &language.name(), cx, ); - if let Some(state) = local.language_servers.get(&server_id) { - if let Ok(uri) = uri { + if let Some(state) = local.language_servers.get(&server_id) + && let Ok(uri) = uri { state.add_workspace_folder(uri); }; - } server_id }); @@ -4805,8 +4788,8 @@ impl LspStore { LocalLspStore::try_resolve_code_action(&lang_server, &mut action) .await .context("resolving a code action")?; - if let Some(edit) = action.lsp_action.edit() { - if edit.changes.is_some() || edit.document_changes.is_some() { + if let Some(edit) = action.lsp_action.edit() + && (edit.changes.is_some() || edit.document_changes.is_some()) { return LocalLspStore::deserialize_workspace_edit( this.upgrade().context("no app present")?, edit.clone(), @@ -4817,7 +4800,6 @@ impl LspStore { ) .await; } - } if let Some(command) = action.lsp_action.command() { let server_capabilities = lang_server.capabilities(); @@ -5736,8 +5718,8 @@ impl LspStore { let version_queried_for = buffer.read(cx).version(); let buffer_id = buffer.read(cx).remote_id(); - if let Some(cached_data) = self.lsp_code_lens.get(&buffer_id) { - if !version_queried_for.changed_since(&cached_data.lens_for_version) { + if let Some(cached_data) = self.lsp_code_lens.get(&buffer_id) + && !version_queried_for.changed_since(&cached_data.lens_for_version) { let has_different_servers = self.as_local().is_some_and(|local| { local .buffers_opened_in_servers @@ -5751,14 +5733,12 @@ impl LspStore { .shared(); } } - } let lsp_data = self.lsp_code_lens.entry(buffer_id).or_default(); - if let Some((updating_for, running_update)) = &lsp_data.update { - if !version_queried_for.changed_since(updating_for) { + if let Some((updating_for, running_update)) = &lsp_data.update + && !version_queried_for.changed_since(updating_for) { return running_update.clone(); } - } let buffer = buffer.clone(); let query_version_queried_for = version_queried_for.clone(); let new_task = cx @@ -6372,12 +6352,11 @@ impl LspStore { .old_replace_start .and_then(deserialize_anchor) .zip(response.old_replace_end.and_then(deserialize_anchor)); - if let Some((old_replace_start, old_replace_end)) = replace_range { - if !response.new_text.is_empty() { + if let Some((old_replace_start, old_replace_end)) = replace_range + && !response.new_text.is_empty() { completion.new_text = response.new_text; completion.replace_range = old_replace_start..old_replace_end; } - } Ok(()) } @@ -6751,8 +6730,8 @@ impl LspStore { LspFetchStrategy::UseCache { known_cache_version, } => { - if let Some(cached_data) = self.lsp_document_colors.get(&buffer_id) { - if !version_queried_for.changed_since(&cached_data.colors_for_version) { + if let Some(cached_data) = self.lsp_document_colors.get(&buffer_id) + && !version_queried_for.changed_since(&cached_data.colors_for_version) { let has_different_servers = self.as_local().is_some_and(|local| { local .buffers_opened_in_servers @@ -6780,16 +6759,14 @@ impl LspStore { } } } - } } } let lsp_data = self.lsp_document_colors.entry(buffer_id).or_default(); - if let Some((updating_for, running_update)) = &lsp_data.colors_update { - if !version_queried_for.changed_since(updating_for) { + if let Some((updating_for, running_update)) = &lsp_data.colors_update + && !version_queried_for.changed_since(updating_for) { return Some(running_update.clone()); } - } let query_version_queried_for = version_queried_for.clone(); let new_task = cx .spawn(async move |lsp_store, cx| { @@ -8785,14 +8762,12 @@ impl LspStore { if summary.is_empty() { if let Some(worktree_summaries) = lsp_store.diagnostic_summaries.get_mut(&worktree_id) - { - if let Some(summaries) = worktree_summaries.get_mut(&path) { + && let Some(summaries) = worktree_summaries.get_mut(&path) { summaries.remove(&server_id); if summaries.is_empty() { worktree_summaries.remove(&path); } } - } } else { lsp_store .diagnostic_summaries @@ -9491,11 +9466,10 @@ impl LspStore { cx: &mut Context, ) { if let Some(status) = self.language_server_statuses.get_mut(&language_server_id) { - if let Some(work) = status.pending_work.remove(&token) { - if !work.is_disk_based_diagnostics_progress { + if let Some(work) = status.pending_work.remove(&token) + && !work.is_disk_based_diagnostics_progress { cx.emit(LspStoreEvent::RefreshInlayHints); } - } cx.notify(); } @@ -10288,11 +10262,10 @@ impl LspStore { None => None, }; - if let Some(server) = server { - if let Some(shutdown) = server.shutdown() { + if let Some(server) = server + && let Some(shutdown) = server.shutdown() { shutdown.await; } - } } // Returns a list of all of the worktrees which no longer have a language server and the root path @@ -10565,8 +10538,8 @@ impl LspStore { for buffer in buffers { buffer.update(cx, |buffer, cx| { language_servers_to_stop.extend(local.language_server_ids_for_buffer(buffer, cx)); - if let Some(worktree_id) = buffer.file().map(|f| f.worktree_id(cx)) { - if covered_worktrees.insert(worktree_id) { + if let Some(worktree_id) = buffer.file().map(|f| f.worktree_id(cx)) + && covered_worktrees.insert(worktree_id) { language_server_names_to_stop.retain(|name| { let old_ids_count = language_servers_to_stop.len(); let all_language_servers_with_this_name = local @@ -10577,7 +10550,6 @@ impl LspStore { old_ids_count == language_servers_to_stop.len() }); } - } }); } for name in language_server_names_to_stop { @@ -11081,11 +11053,10 @@ impl LspStore { 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 { + if let Some(token_to_cancel) = token_to_cancel.as_ref() + && token != token_to_cancel { continue; } - } if progress.is_cancellable { server .notify::( @@ -11191,8 +11162,7 @@ impl LspStore { for server_id in &language_server_ids { if let Some(LanguageServerState::Running { server, .. }) = local.language_servers.get(server_id) - { - if let Some(watched_paths) = local + && let Some(watched_paths) = local .language_server_watched_paths .get(server_id) .and_then(|paths| paths.worktree_paths.get(&worktree_id)) @@ -11224,7 +11194,6 @@ impl LspStore { .ok(); } } - } } for (path, _, _) in changes { if let Some(file_name) = path.file_name().and_then(|file_name| file_name.to_str()) diff --git a/crates/project/src/manifest_tree/path_trie.rs b/crates/project/src/manifest_tree/path_trie.rs index 1a0736765a..4d7d2bd78f 100644 --- a/crates/project/src/manifest_tree/path_trie.rs +++ b/crates/project/src/manifest_tree/path_trie.rs @@ -84,11 +84,10 @@ impl RootPathTrie