Auto-fix clippy::collapsible_if violations (#36428)

Piotr Osiewicz created

Release Notes:

- N/A

Change summary

Cargo.toml                                                                |   1 
crates/acp_thread/src/acp_thread.rs                                       |  25 
crates/action_log/src/action_log.rs                                       |   8 
crates/activity_indicator/src/activity_indicator.rs                       |  65 
crates/agent/src/context.rs                                               |  36 
crates/agent/src/context_store.rs                                         |   8 
crates/agent/src/thread.rs                                                |  49 
crates/agent/src/thread_store.rs                                          |  62 
crates/agent/src/tool_use.rs                                              |  20 
crates/agent2/src/thread.rs                                               |  12 
crates/agent2/src/tools/edit_file_tool.rs                                 |  14 
crates/agent2/src/tools/grep_tool.rs                                      |  10 
crates/agent_servers/src/claude.rs                                        |  16 
crates/agent_settings/src/agent_settings.rs                               |  16 
crates/agent_ui/src/acp/thread_view.rs                                    | 170 
crates/agent_ui/src/active_thread.rs                                      | 136 
crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs |  32 
crates/agent_ui/src/agent_configuration/tool_picker.rs                    |   8 
crates/agent_ui/src/agent_diff.rs                                         |  68 
crates/agent_ui/src/agent_panel.rs                                        |  13 
crates/agent_ui/src/buffer_codegen.rs                                     |  68 
crates/agent_ui/src/context_strip.rs                                      |   8 
crates/agent_ui/src/inline_assistant.rs                                   | 113 
crates/agent_ui/src/terminal_inline_assistant.rs                          |  59 
crates/agent_ui/src/text_thread_editor.rs                                 |  39 
crates/agent_ui/src/thread_history.rs                                     |   9 
crates/assistant_context/src/assistant_context.rs                         | 122 
crates/assistant_context/src/context_store.rs                             |  47 
crates/assistant_slash_commands/src/context_server_command.rs             |   8 
crates/assistant_slash_commands/src/delta_command.rs                      |  69 
crates/assistant_slash_commands/src/diagnostics_command.rs                |   8 
crates/assistant_slash_commands/src/tab_command.rs                        |  16 
crates/assistant_tool/src/tool_schema.rs                                  |  38 
crates/assistant_tools/src/edit_agent.rs                                  |  45 
crates/assistant_tools/src/edit_agent/evals.rs                            |  16 
crates/assistant_tools/src/edit_file_tool.rs                              |  16 
crates/assistant_tools/src/grep_tool.rs                                   |  10 
crates/assistant_tools/src/schema.rs                                      |  11 
crates/auto_update_helper/src/dialog.rs                                   |  10 
crates/breadcrumbs/src/breadcrumbs.rs                                     |  11 
crates/buffer_diff/src/buffer_diff.rs                                     |  29 
crates/call/src/call_impl/room.rs                                         |  62 
crates/channel/src/channel_buffer.rs                                      |  11 
crates/channel/src/channel_chat.rs                                        | 121 
crates/channel/src/channel_store.rs                                       |  78 
crates/cli/src/main.rs                                                    |   9 
crates/client/src/client.rs                                               |  29 
crates/client/src/user.rs                                                 |   8 
crates/collab/src/api/events.rs                                           | 160 
crates/collab/src/api/extensions.rs                                       |  14 
crates/collab/src/auth.rs                                                 |  38 
crates/collab/src/db/queries/extensions.rs                                |  16 
crates/collab/src/db/queries/projects.rs                                  |   8 
crates/collab/src/rpc.rs                                                  |  93 
crates/collab/src/tests/random_project_collaboration_tests.rs             |   5 
crates/collab/src/tests/randomized_test_helpers.rs                        |  30 
crates/collab/src/user_backfiller.rs                                      |  22 
crates/collab_ui/src/channel_view.rs                                      |  80 
crates/collab_ui/src/chat_panel.rs                                        |  83 
crates/collab_ui/src/chat_panel/message_editor.rs                         |  65 
crates/collab_ui/src/collab_panel.rs                                      | 181 
crates/collab_ui/src/notification_panel.rs                                |  76 
crates/context_server/src/client.rs                                       |   8 
crates/copilot/src/copilot.rs                                             | 121 
crates/dap_adapters/src/javascript.rs                                     |   8 
crates/debugger_tools/src/dap_log.rs                                      |  10 
crates/debugger_ui/src/debugger_panel.rs                                  |  13 
crates/debugger_ui/src/new_process_modal.rs                               |   8 
crates/debugger_ui/src/session/running/breakpoint_list.rs                 |  40 
crates/debugger_ui/src/session/running/console.rs                         |  17 
crates/diagnostics/src/diagnostics.rs                                     |  38 
crates/editor/src/display_map.rs                                          |  36 
crates/editor/src/display_map/block_map.rs                                | 146 
crates/editor/src/display_map/fold_map.rs                                 |  60 
crates/editor/src/display_map/inlay_map.rs                                |  10 
crates/editor/src/display_map/wrap_map.rs                                 |  94 
crates/editor/src/editor.rs                                               | 724 
crates/editor/src/element.rs                                              | 261 
crates/editor/src/git/blame.rs                                            |  31 
crates/editor/src/hover_links.rs                                          |  41 
crates/editor/src/hover_popover.rs                                        | 135 
crates/editor/src/indent_guides.rs                                        |  10 
crates/editor/src/inlay_hint_cache.rs                                     | 121 
crates/editor/src/items.rs                                                |  61 
crates/editor/src/jsx_tag_auto_close.rs                                   |  17 
crates/editor/src/lsp_ext.rs                                              |  19 
crates/editor/src/movement.rs                                             |  50 
crates/editor/src/rust_analyzer_ext.rs                                    |  10 
crates/editor/src/scroll.rs                                               |  24 
crates/editor/src/scroll/autoscroll.rs                                    |  12 
crates/editor/src/test.rs                                                 |   8 
crates/eval/src/eval.rs                                                   |   5 
crates/eval/src/explorer.rs                                               |  28 
crates/eval/src/instance.rs                                               |   5 
crates/extension/src/extension.rs                                         |  17 
crates/extension_host/src/extension_host.rs                               |  71 
crates/extension_host/src/wasm_host.rs                                    |  17 
crates/extensions_ui/src/extensions_ui.rs                                 |  15 
crates/file_finder/src/file_finder.rs                                     | 401 
crates/file_finder/src/open_path_prompt.rs                                |  20 
crates/fs/src/fs.rs                                                       |  82 
crates/fs/src/mac_watcher.rs                                              |   5 
crates/fsevent/src/fsevent.rs                                             |  65 
crates/git/src/blame.rs                                                   |  12 
crates/git/src/repository.rs                                              |  16 
crates/git_hosting_providers/src/git_hosting_providers.rs                 |   8 
crates/git_ui/src/commit_modal.rs                                         |  19 
crates/git_ui/src/git_panel.rs                                            |  42 
crates/git_ui/src/project_diff.rs                                         |   8 
crates/go_to_line/src/cursor_position.rs                                  |  16 
crates/go_to_line/src/go_to_line.rs                                       |  10 
crates/google_ai/src/google_ai.rs                                         |   5 
crates/gpui/build.rs                                                      |  15 
crates/gpui/examples/input.rs                                             |   8 
crates/gpui/src/app.rs                                                    |  40 
crates/gpui/src/app/context.rs                                            |  20 
crates/gpui/src/element.rs                                                |   6 
crates/gpui/src/elements/div.rs                                           | 233 
crates/gpui/src/elements/image_cache.rs                                   |   8 
crates/gpui/src/elements/img.rs                                           |  13 
crates/gpui/src/elements/list.rs                                          |  74 
crates/gpui/src/elements/text.rs                                          |  32 
crates/gpui/src/keymap/binding.rs                                         |   8 
crates/gpui/src/platform/blade/blade_renderer.rs                          |  30 
crates/gpui/src/platform/linux/wayland/client.rs                          |  52 
crates/gpui/src/platform/linux/wayland/cursor.rs                          |   9 
crates/gpui/src/platform/linux/wayland/window.rs                          |  27 
crates/gpui/src/platform/linux/x11/client.rs                              |  29 
crates/gpui/src/platform/linux/x11/clipboard.rs                           |  38 
crates/gpui/src/platform/linux/x11/window.rs                              |  49 
crates/gpui/src/platform/mac/open_type.rs                                 |  16 
crates/gpui/src/platform/mac/platform.rs                                  |  27 
crates/gpui/src/platform/mac/window.rs                                    |  41 
crates/gpui/src/platform/test/dispatcher.rs                               |  10 
crates/gpui/src/platform/test/platform.rs                                 |   8 
crates/gpui/src/platform/windows/events.rs                                |  75 
crates/gpui/src/platform/windows/platform.rs                              |  16 
crates/gpui/src/text_system.rs                                            |  43 
crates/gpui/src/text_system/line.rs                                       |  24 
crates/gpui/src/text_system/line_layout.rs                                |   8 
crates/gpui/src/view.rs                                                   |  31 
crates/gpui/src/window.rs                                                 |  68 
crates/gpui_macros/src/derive_inspector_reflection.rs                     |  18 
crates/gpui_macros/src/test.rs                                            | 116 
crates/html_to_markdown/src/markdown.rs                                   |  17 
crates/http_client/src/github.rs                                          |   8 
crates/journal/src/journal.rs                                             |  32 
crates/language/src/buffer.rs                                             | 215 
crates/language/src/language.rs                                           |  33 
crates/language/src/syntax_map.rs                                         | 104 
crates/language/src/text_diff.rs                                          |  10 
crates/language_model/src/request.rs                                      |  41 
crates/language_models/src/provider/anthropic.rs                          |  10 
crates/language_models/src/provider/bedrock.rs                            |  18 
crates/language_models/src/provider/cloud.rs                              |  52 
crates/language_selector/src/active_buffer_language.rs                    |   8 
crates/language_tools/src/lsp_log.rs                                      | 116 
crates/language_tools/src/syntax_tree_view.rs                             |  23 
crates/languages/src/go.rs                                                |  24 
crates/languages/src/lib.rs                                               |   7 
crates/languages/src/python.rs                                            |  96 
crates/languages/src/rust.rs                                              |   8 
crates/languages/src/typescript.rs                                        |   8 
crates/livekit_client/src/test.rs                                         |  16 
crates/markdown/src/markdown.rs                                           |  71 
crates/markdown_preview/src/markdown_parser.rs                            |  21 
crates/markdown_preview/src/markdown_preview_view.rs                      |  52 
crates/migrator/src/migrations/m_2025_06_16/settings.rs                   |  28 
crates/migrator/src/migrations/m_2025_06_25/settings.rs                   |  16 
crates/migrator/src/migrations/m_2025_06_27/settings.rs                   |  25 
crates/multi_buffer/src/anchor.rs                                         | 113 
crates/multi_buffer/src/multi_buffer.rs                                   | 475 
crates/multi_buffer/src/multi_buffer_tests.rs                             |  32 
crates/notifications/src/notification_store.rs                            |  53 
crates/open_router/src/open_router.rs                                     |   8 
crates/outline_panel/src/outline_panel.rs                                 | 238 
crates/prettier/src/prettier.rs                                           |  38 
crates/project/src/buffer_store.rs                                        |  32 
crates/project/src/debugger/breakpoint_store.rs                           |  11 
crates/project/src/debugger/memory.rs                                     |  13 
crates/project/src/git_store.rs                                           | 152 
crates/project/src/git_store/git_traversal.rs                             |  10 
crates/project/src/lsp_command.rs                                         |  26 
crates/project/src/lsp_store.rs                                           | 392 
crates/project/src/manifest_tree/path_trie.rs                             |  10 
crates/project/src/prettier_store.rs                                      |  21 
crates/project/src/project.rs                                             | 147 
crates/project/src/search.rs                                              |  16 
crates/project/src/search_history.rs                                      |  23 
crates/project/src/terminals.rs                                           |  52 
crates/project_panel/src/project_panel.rs                                 | 491 
crates/prompt_store/src/prompts.rs                                        |  19 
crates/proto/src/error.rs                                                 |   8 
crates/recent_projects/src/remote_servers.rs                              |   8 
crates/refineable/derive_refineable/src/derive_refineable.rs              |  12 
crates/remote/src/ssh_session.rs                                          |  41 
crates/remote_server/src/unix.rs                                          |  14 
crates/repl/src/kernels/native_kernel.rs                                  |  24 
crates/repl/src/outputs.rs                                                |  39 
crates/repl/src/repl_editor.rs                                            |   8 
crates/repl/src/repl_sessions_ui.rs                                       |  25 
crates/repl/src/repl_store.rs                                             |   8 
crates/reqwest_client/src/reqwest_client.rs                               |  11 
crates/rich_text/src/rich_text.rs                                         |  21 
crates/rope/src/rope.rs                                                   |  43 
crates/rpc/src/notification.rs                                            |   8 
crates/rpc/src/peer.rs                                                    |   8 
crates/rules_library/src/rules_library.rs                                 |  34 
crates/search/src/buffer_search.rs                                        | 180 
crates/search/src/project_search.rs                                       |  45 
crates/semantic_index/src/embedding_index.rs                              |  10 
crates/semantic_index/src/project_index.rs                                |   8 
crates/semantic_index/src/semantic_index.rs                               |  15 
crates/semantic_index/src/summary_index.rs                                |  20 
crates/session/src/session.rs                                             |  10 
crates/settings/src/keymap_file.rs                                        |  48 
crates/settings/src/settings_file.rs                                      |  27 
crates/settings/src/settings_json.rs                                      |  17 
crates/settings/src/settings_store.rs                                     | 109 
crates/snippets_ui/src/snippets_ui.rs                                     |  13 
crates/sqlez/src/connection.rs                                            |  63 
crates/sum_tree/src/cursor.rs                                             |   8 
crates/sum_tree/src/sum_tree.rs                                           |  30 
crates/svg_preview/src/svg_preview_view.rs                                | 160 
crates/task/src/debug_format.rs                                           |   9 
crates/task/src/vscode_debug_format.rs                                    |  12 
crates/tasks_ui/src/tasks_ui.rs                                           |  17 
crates/terminal/src/terminal.rs                                           |  36 
crates/terminal/src/terminal_settings.rs                                  |   8 
crates/terminal_view/src/terminal_element.rs                              |  29 
crates/terminal_view/src/terminal_panel.rs                                |  23 
crates/terminal_view/src/terminal_view.rs                                 |  80 
crates/text/src/text.rs                                                   |  26 
crates/theme/src/fallback_themes.rs                                       |   8 
crates/title_bar/src/application_menu.rs                                  |  43 
crates/title_bar/src/title_bar.rs                                         |  10 
crates/toolchain_selector/src/active_toolchain.rs                         |  47 
crates/toolchain_selector/src/toolchain_selector.rs                       |   9 
crates/ui/src/components/label/highlighted_label.rs                       |  12 
crates/ui/src/components/popover_menu.rs                                  |  32 
crates/ui/src/components/right_click_menu.rs                              |   9 
crates/util/src/fs.rs                                                     |  27 
crates/util/src/schemars.rs                                               |  13 
crates/util/src/util.rs                                                   |   8 
crates/vim/src/command.rs                                                 |  55 
crates/vim/src/digraph.rs                                                 |  16 
crates/vim/src/motion.rs                                                  |  24 
crates/vim/src/normal/delete.rs                                           |   8 
crates/vim/src/normal/mark.rs                                             |   6 
crates/vim/src/normal/repeat.rs                                           |  24 
crates/vim/src/object.rs                                                  |  56 
crates/vim/src/state.rs                                                   |  71 
crates/vim/src/surrounds.rs                                               |  22 
crates/vim/src/test/neovim_connection.rs                                  |   9 
crates/vim/src/vim.rs                                                     |  54 
crates/workspace/src/dock.rs                                              |  41 
crates/workspace/src/history_manager.rs                                   |  10 
crates/workspace/src/item.rs                                              |  26 
crates/workspace/src/modal_layer.rs                                       |   8 
crates/workspace/src/pane.rs                                              | 133 
crates/workspace/src/pane_group.rs                                        |  55 
crates/workspace/src/workspace.rs                                         | 434 
crates/workspace/src/workspace_settings.rs                                |  28 
crates/worktree/src/worktree.rs                                           | 126 
crates/zed/build.rs                                                       |  26 
crates/zed/src/main.rs                                                    | 113 
crates/zed/src/reliability.rs                                             |  43 
crates/zed/src/zed.rs                                                     |  73 
crates/zed/src/zed/component_preview.rs                                   |  99 
crates/zed/src/zed/edit_prediction_registry.rs                            |  42 
crates/zed/src/zed/mac_only_instance.rs                                   |  23 
crates/zed/src/zed/open_listener.rs                                       |  65 
crates/zeta/src/rate_completion_modal.rs                                  |  12 
crates/zeta/src/zeta.rs                                                   |   9 
crates/zlog/src/sink.rs                                                   |   8 
crates/zlog/src/zlog.rs                                                   |  30 
extensions/glsl/src/glsl.rs                                               |   8 
extensions/ruff/src/ruff.rs                                               |  14 
extensions/snippets/src/snippets.rs                                       |   8 
extensions/test-extension/src/test_extension.rs                           |   8 
extensions/toml/src/toml.rs                                               |  14 
281 files changed, 6,605 insertions(+), 7,062 deletions(-)

Detailed changes

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"

crates/acp_thread/src/acp_thread.rs πŸ”—

@@ -249,14 +249,13 @@ 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)
-                {
-                    self.content
-                        .push(ToolCallContent::ContentBlock(ContentBlock::Markdown {
-                            markdown,
-                        }));
-                }
+            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,11 +429,11 @@ impl ContentBlock {
         language_registry: &Arc<LanguageRegistry>,
         cx: &mut App,
     ) {
-        if matches!(self, ContentBlock::Empty) {
-            if let acp::ContentBlock::ResourceLink(resource_link) = block {
-                *self = ContentBlock::ResourceLink { resource_link };
-                return;
-            }
+        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);

crates/action_log/src/action_log.rs πŸ”—

@@ -614,10 +614,10 @@ impl ActionLog {
                         false
                     }
                 });
-                if tracked_buffer.unreviewed_edits.is_empty() {
-                    if let TrackedBufferStatus::Created { .. } = &mut tracked_buffer.status {
-                        tracked_buffer.status = TrackedBufferStatus::Modified;
-                    }
+                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);
             }

crates/activity_indicator/src/activity_indicator.rs πŸ”—

@@ -458,26 +458,24 @@ 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 {
-                return Some(Content {
-                    icon: Some(
-                        Icon::new(IconName::ArrowCircle)
-                            .size(IconSize::Small)
-                            .with_animation(
-                                "arrow-circle",
-                                Animation::new(Duration::from_secs(2)).repeat(),
-                                |icon, delta| {
-                                    icon.transform(Transformation::rotate(percentage(delta)))
-                                },
-                            )
-                            .into_any_element(),
-                    ),
-                    message: job_info.message.into(),
-                    on_click: None,
-                    tooltip_message: None,
-                });
-            }
+        if let Some(job_info) = current_job
+            && Instant::now() - job_info.start >= GIT_OPERATION_DELAY
+        {
+            return Some(Content {
+                icon: Some(
+                    Icon::new(IconName::ArrowCircle)
+                        .size(IconSize::Small)
+                        .with_animation(
+                            "arrow-circle",
+                            Animation::new(Duration::from_secs(2)).repeat(),
+                            |icon, delta| icon.transform(Transformation::rotate(percentage(delta))),
+                        )
+                        .into_any_element(),
+                ),
+                message: job_info.message.into(),
+                on_click: None,
+                tooltip_message: None,
+            });
         }
 
         // Show any language server installation info.
@@ -740,21 +738,20 @@ impl ActivityIndicator {
 
         if let Some(extension_store) =
             ExtensionStore::try_global(cx).map(|extension_store| extension_store.read(cx))
+            && let Some(extension_id) = extension_store.outstanding_operations().keys().next()
         {
-            if let Some(extension_id) = extension_store.outstanding_operations().keys().next() {
-                return Some(Content {
-                    icon: Some(
-                        Icon::new(IconName::Download)
-                            .size(IconSize::Small)
-                            .into_any_element(),
-                    ),
-                    message: format!("Updating {extension_id} extension…"),
-                    on_click: Some(Arc::new(|this, window, cx| {
-                        this.dismiss_error_message(&DismissErrorMessage, window, cx)
-                    })),
-                    tooltip_message: None,
-                });
-            }
+            return Some(Content {
+                icon: Some(
+                    Icon::new(IconName::Download)
+                        .size(IconSize::Small)
+                        .into_any_element(),
+                ),
+                message: format!("Updating {extension_id} extension…"),
+                on_click: Some(Arc::new(|this, window, cx| {
+                    this.dismiss_error_message(&DismissErrorMessage, window, cx)
+                })),
+                tooltip_message: None,
+            });
         }
 
         None

crates/agent/src/context.rs πŸ”—

@@ -201,24 +201,24 @@ 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) {
-                            let items = outline
-                                .items
-                                .into_iter()
-                                .map(|item| item.to_point(&snapshot));
-
-                            if let Ok(outline_text) =
-                                outline::render_outline(items, None, 0, usize::MAX).await
-                            {
-                                let context = AgentContext::File(FileContext {
-                                    handle: self,
-                                    full_path,
-                                    text: outline_text.into(),
-                                    is_outline: true,
-                                });
-                                return Some((context, vec![buffer]));
-                            }
+                    if let Ok(snapshot) = buffer.read_with(cx, |buffer, _| buffer.snapshot())
+                        && let Some(outline) = snapshot.outline(None)
+                    {
+                        let items = outline
+                            .items
+                            .into_iter()
+                            .map(|item| item.to_point(&snapshot));
+
+                        if let Ok(outline_text) =
+                            outline::render_outline(items, None, 0, usize::MAX).await
+                        {
+                            let context = AgentContext::File(FileContext {
+                                handle: self,
+                                full_path,
+                                text: outline_text.into(),
+                                is_outline: true,
+                            });
+                            return Some((context, vec![buffer]));
                         }
                     }
                 }

crates/agent/src/context_store.rs πŸ”—

@@ -338,11 +338,9 @@ impl ContextStore {
             image_task,
             context_id: self.next_context_id.post_inc(),
         });
-        if self.has_context(&context) {
-            if remove_if_exists {
-                self.remove_context(&context, cx);
-                return None;
-            }
+        if self.has_context(&context) && remove_if_exists {
+            self.remove_context(&context, cx);
+            return None;
         }
 
         self.insert_context(context.clone(), cx);

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,13 +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();
-                }
+                })
+            {
+                save_task.await.log_err();
             }
 
             Some(())
@@ -2730,12 +2728,11 @@ impl Thread {
         window: Option<AnyWindowHandle>,
         cx: &mut Context<Self>,
     ) {
-        if self.all_tools_finished() {
-            if let Some(ConfiguredModel { model, .. }) = self.configured_model.as_ref() {
-                if !canceled {
-                    self.send_to_model(model.clone(), CompletionIntent::ToolResults, window, cx);
-                }
-            }
+        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 {
@@ -2922,11 +2919,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() {
-                            let path = file.path().to_string_lossy().to_string();
-                            unsaved_buffers.push(path);
-                        }
+                    if buffer.is_dirty()
+                        && let Some(file) = buffer.file()
+                    {
+                        let path = file.path().to_string_lossy().to_string();
+                        unsaved_buffers.push(path);
                     }
                 }
             })
@@ -3178,13 +3175,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 {
-                return Some(TotalTokenUsage {
-                    total: exceeded_error.token_count,
-                    max,
-                });
-            }
+        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

crates/agent/src/thread_store.rs πŸ”—

@@ -581,33 +581,32 @@ 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::<context_server::types::requests::ListTools>(())
                     .await
                     .log_err()
-                {
-                    let tool_ids = tool_working_set
-                        .update(cx, |tool_working_set, cx| {
-                            tool_working_set.extend(
-                                response.tools.into_iter().map(|tool| {
-                                    Arc::new(ContextServerTool::new(
-                                        context_server_store.clone(),
-                                        server.id(),
-                                        tool,
-                                    )) as Arc<dyn Tool>
-                                }),
-                                cx,
-                            )
-                        })
-                        .log_err();
-
-                    if let Some(tool_ids) = tool_ids {
-                        this.update(cx, |this, _| {
-                            this.context_server_tool_ids.insert(server_id, tool_ids);
-                        })
-                        .log_err();
-                    }
+            {
+                let tool_ids = tool_working_set
+                    .update(cx, |tool_working_set, cx| {
+                        tool_working_set.extend(
+                            response.tools.into_iter().map(|tool| {
+                                Arc::new(ContextServerTool::new(
+                                    context_server_store.clone(),
+                                    server.id(),
+                                    tool,
+                                )) as Arc<dyn Tool>
+                            }),
+                            cx,
+                        )
+                    })
+                    .log_err();
+
+                if let Some(tool_ids) = tool_ids {
+                    this.update(cx, |this, _| {
+                        this.context_server_tool_ids.insert(server_id, tool_ids);
+                    })
+                    .log_err();
                 }
             }
         })
@@ -697,13 +696,14 @@ impl SerializedThreadV0_1_0 {
         let mut messages: Vec<SerializedMessage> = 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() {
-                    debug_assert!(last_message.role == Role::Assistant);
-
-                    last_message.tool_results = message.tool_results;
-                    continue;
-                }
+            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);

crates/agent/src/tool_use.rs πŸ”—

@@ -112,19 +112,13 @@ 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(
-                                            output,
-                                            project.clone(),
-                                            window,
-                                            cx,
-                                        ) {
-                                            this.tool_result_cards.insert(tool_use_id, 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, cx)
+                            {
+                                this.tool_result_cards.insert(tool_use_id, card);
                             }
                         }
                     }

crates/agent2/src/thread.rs πŸ”—

@@ -1037,12 +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 {
-                        return Err(anyhow!(
-                            "Attempted to read an image, but this model doesn't support it.",
-                        ));
-                    }
+                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)
             });

crates/agent2/src/tools/edit_file_tool.rs πŸ”—

@@ -156,13 +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()) {
-                return event_stream.authorize(
-                    format!("{} (global settings)", input.display_description),
-                    cx,
-                );
-            }
+        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

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;
                 }

crates/agent_servers/src/claude.rs πŸ”—

@@ -203,14 +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() {
-                            thread
-                                .update(cx, |thread, cx| {
-                                    thread.emit_server_exited(status, cx);
-                                })
-                                .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();
                     }
                 }
             });

crates/agent_settings/src/agent_settings.rs πŸ”—

@@ -116,15 +116,15 @@ pub struct LanguageModelParameters {
 
 impl LanguageModelParameters {
     pub fn matches(&self, model: &Arc<dyn LanguageModel>) -> bool {
-        if let Some(provider) = &self.provider {
-            if provider.0 != model.provider_id().0 {
-                return false;
-            }
+        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 {
-                return false;
-            }
+        if let Some(setting_model) = &self.model
+            && *setting_model != model.id().0
+        {
+            return false;
         }
         true
     }

crates/agent_ui/src/acp/thread_view.rs πŸ”—

@@ -371,20 +371,20 @@ 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 {
-                            this.update(cx, |this, cx| {
-                                this.thread_state = Self::initial_state(
-                                    agent.clone(),
-                                    this.workspace.clone(),
-                                    this.project.clone(),
-                                    window,
-                                    cx,
-                                );
-                                cx.notify();
-                            })
-                            .ok();
-                        }
+                    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(),
+                                this.workspace.clone(),
+                                this.project.clone(),
+                                window,
+                                cx,
+                            );
+                            cx.notify();
+                        })
+                        .ok();
                     }
                 }
             });
@@ -547,11 +547,11 @@ impl AcpThreadView {
     }
 
     fn send(&mut self, window: &mut Window, cx: &mut Context<Self>) {
-        if let Some(thread) = self.thread() {
-            if thread.read(cx).status() != ThreadStatus::Idle {
-                self.stop_current_and_send_new_message(window, cx);
-                return;
-            }
+        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
@@ -628,25 +628,24 @@ 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)
                 .and_then(|e| e.message_editor())
                 .cloned()
-            {
-                editor.update(cx, |editor, cx| {
-                    if let Some(user_message) = thread
-                        .read(cx)
-                        .entries()
-                        .get(index)
-                        .and_then(|e| e.user_message())
-                    {
-                        editor.set_message(user_message.chunks.clone(), window, cx);
-                    }
-                })
-            }
+        {
+            editor.update(cx, |editor, cx| {
+                if let Some(user_message) = thread
+                    .read(cx)
+                    .entries()
+                    .get(index)
+                    .and_then(|e| e.user_message())
+                {
+                    editor.set_message(user_message.chunks.clone(), window, cx);
+                }
+            })
         };
         self.focus_handle(cx).focus(window);
         cx.notify();
@@ -3265,62 +3264,61 @@ impl AcpThreadView {
                 })
             })
             .log_err()
+            && let Some(pop_up) = screen_window.entity(cx).log_err()
         {
-            if let Some(pop_up) = screen_window.entity(cx).log_err() {
-                self.notification_subscriptions
-                    .entry(screen_window)
-                    .or_insert_with(Vec::new)
-                    .push(cx.subscribe_in(&pop_up, window, {
-                        |this, _, event, window, cx| match event {
-                            AgentNotificationEvent::Accepted => {
-                                let handle = window.window_handle();
-                                cx.activate(true);
-
-                                let workspace_handle = this.workspace.clone();
-
-                                // If there are multiple Zed windows, activate the correct one.
-                                cx.defer(move |cx| {
-                                    handle
-                                        .update(cx, |_view, window, _cx| {
-                                            window.activate_window();
-
-                                            if let Some(workspace) = workspace_handle.upgrade() {
-                                                workspace.update(_cx, |workspace, cx| {
-                                                    workspace.focus_panel::<AgentPanel>(window, cx);
-                                                });
-                                            }
-                                        })
-                                        .log_err();
-                                });
+            self.notification_subscriptions
+                .entry(screen_window)
+                .or_insert_with(Vec::new)
+                .push(cx.subscribe_in(&pop_up, window, {
+                    |this, _, event, window, cx| match event {
+                        AgentNotificationEvent::Accepted => {
+                            let handle = window.window_handle();
+                            cx.activate(true);
+
+                            let workspace_handle = this.workspace.clone();
+
+                            // If there are multiple Zed windows, activate the correct one.
+                            cx.defer(move |cx| {
+                                handle
+                                    .update(cx, |_view, window, _cx| {
+                                        window.activate_window();
+
+                                        if let Some(workspace) = workspace_handle.upgrade() {
+                                            workspace.update(_cx, |workspace, cx| {
+                                                workspace.focus_panel::<AgentPanel>(window, cx);
+                                            });
+                                        }
+                                    })
+                                    .log_err();
+                            });
 
-                                this.dismiss_notifications(cx);
-                            }
-                            AgentNotificationEvent::Dismissed => {
-                                this.dismiss_notifications(cx);
-                            }
+                            this.dismiss_notifications(cx);
                         }
-                    }));
-
-                self.notifications.push(screen_window);
-
-                // If the user manually refocuses the original window, dismiss the popup.
-                self.notification_subscriptions
-                    .entry(screen_window)
-                    .or_insert_with(Vec::new)
-                    .push({
-                        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() {
-                                    pop_up.update(cx, |_, cx| {
-                                        cx.emit(AgentNotificationEvent::Dismissed);
-                                    });
-                                }
-                            }
-                        })
-                    });
-            }
+                        AgentNotificationEvent::Dismissed => {
+                            this.dismiss_notifications(cx);
+                        }
+                    }
+                }));
+
+            self.notifications.push(screen_window);
+
+            // If the user manually refocuses the original window, dismiss the popup.
+            self.notification_subscriptions
+                .entry(screen_window)
+                .or_insert_with(Vec::new)
+                .push({
+                    let pop_up_weak = pop_up.downgrade();
+
+                    cx.observe_window_activation(window, move |_, window, cx| {
+                        if window.is_window_active()
+                            && let Some(pop_up) = pop_up_weak.upgrade()
+                        {
+                            pop_up.update(cx, |_, cx| {
+                                cx.emit(AgentNotificationEvent::Dismissed);
+                            });
+                        }
+                    })
+                });
         }
     }
 

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(),
@@ -1084,14 +1084,14 @@ impl ActiveThread {
                             }
                             rendered_message
                         })
-                    }) {
-                        self.list_state.splice(index..index + 1, 1);
-                        self.rendered_messages_by_id
-                            .insert(*message_id, rendered_message);
-                        self.scroll_to_bottom(cx);
-                        self.save_thread(cx);
-                        cx.notify();
-                    }
+                    })
+                {
+                    self.list_state.splice(index..index + 1, 1);
+                    self.rendered_messages_by_id
+                        .insert(*message_id, rendered_message);
+                    self.scroll_to_bottom(cx);
+                    self.save_thread(cx);
+                    cx.notify();
                 }
             }
             ThreadEvent::MessageDeleted(message_id) => {
@@ -1272,62 +1272,61 @@ impl ActiveThread {
                 })
             })
             .log_err()
+            && let Some(pop_up) = screen_window.entity(cx).log_err()
         {
-            if let Some(pop_up) = screen_window.entity(cx).log_err() {
-                self.notification_subscriptions
-                    .entry(screen_window)
-                    .or_insert_with(Vec::new)
-                    .push(cx.subscribe_in(&pop_up, window, {
-                        |this, _, event, window, cx| match event {
-                            AgentNotificationEvent::Accepted => {
-                                let handle = window.window_handle();
-                                cx.activate(true);
-
-                                let workspace_handle = this.workspace.clone();
-
-                                // If there are multiple Zed windows, activate the correct one.
-                                cx.defer(move |cx| {
-                                    handle
-                                        .update(cx, |_view, window, _cx| {
-                                            window.activate_window();
-
-                                            if let Some(workspace) = workspace_handle.upgrade() {
-                                                workspace.update(_cx, |workspace, cx| {
-                                                    workspace.focus_panel::<AgentPanel>(window, cx);
-                                                });
-                                            }
-                                        })
-                                        .log_err();
-                                });
+            self.notification_subscriptions
+                .entry(screen_window)
+                .or_insert_with(Vec::new)
+                .push(cx.subscribe_in(&pop_up, window, {
+                    |this, _, event, window, cx| match event {
+                        AgentNotificationEvent::Accepted => {
+                            let handle = window.window_handle();
+                            cx.activate(true);
+
+                            let workspace_handle = this.workspace.clone();
+
+                            // If there are multiple Zed windows, activate the correct one.
+                            cx.defer(move |cx| {
+                                handle
+                                    .update(cx, |_view, window, _cx| {
+                                        window.activate_window();
+
+                                        if let Some(workspace) = workspace_handle.upgrade() {
+                                            workspace.update(_cx, |workspace, cx| {
+                                                workspace.focus_panel::<AgentPanel>(window, cx);
+                                            });
+                                        }
+                                    })
+                                    .log_err();
+                            });
 
-                                this.dismiss_notifications(cx);
-                            }
-                            AgentNotificationEvent::Dismissed => {
-                                this.dismiss_notifications(cx);
-                            }
+                            this.dismiss_notifications(cx);
                         }
-                    }));
-
-                self.notifications.push(screen_window);
-
-                // If the user manually refocuses the original window, dismiss the popup.
-                self.notification_subscriptions
-                    .entry(screen_window)
-                    .or_insert_with(Vec::new)
-                    .push({
-                        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() {
-                                    pop_up.update(cx, |_, cx| {
-                                        cx.emit(AgentNotificationEvent::Dismissed);
-                                    });
-                                }
-                            }
-                        })
-                    });
-            }
+                        AgentNotificationEvent::Dismissed => {
+                            this.dismiss_notifications(cx);
+                        }
+                    }
+                }));
+
+            self.notifications.push(screen_window);
+
+            // If the user manually refocuses the original window, dismiss the popup.
+            self.notification_subscriptions
+                .entry(screen_window)
+                .or_insert_with(Vec::new)
+                .push({
+                    let pop_up_weak = pop_up.downgrade();
+
+                    cx.observe_window_activation(window, move |_, window, cx| {
+                        if window.is_window_active()
+                            && let Some(pop_up) = pop_up_weak.upgrade()
+                        {
+                            pop_up.update(cx, |_, cx| {
+                                cx.emit(AgentNotificationEvent::Dismissed);
+                            });
+                        }
+                    })
+                });
         }
     }
 
@@ -2269,13 +2268,12 @@ impl ActiveThread {
                     let mut error = None;
                     if let Some(last_restore_checkpoint) =
                         self.thread.read(cx).last_restore_checkpoint()
+                        && last_restore_checkpoint.message_id() == message_id
                     {
-                        if last_restore_checkpoint.message_id() == message_id {
-                            match last_restore_checkpoint {
-                                LastRestoreCheckpoint::Pending { .. } => is_pending = true,
-                                LastRestoreCheckpoint::Error { error: err, .. } => {
-                                    error = Some(err.clone());
-                                }
+                        match last_restore_checkpoint {
+                            LastRestoreCheckpoint::Pending { .. } => is_pending = true,
+                            LastRestoreCheckpoint::Error { error: err, .. } => {
+                                error = Some(err.clone());
                             }
                         }
                     }

crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs πŸ”—

@@ -163,10 +163,10 @@ impl ConfigurationSource {
                     .read(cx)
                     .text(cx);
                 let settings = serde_json_lenient::from_str::<serde_json::Value>(&text)?;
-                if let Some(settings_validator) = settings_validator {
-                    if let Err(error) = settings_validator.validate(&settings) {
-                        return Err(anyhow::anyhow!(error.to_string()));
-                    }
+                if let Some(settings_validator) = settings_validator
+                    && let Err(error) = settings_validator.validate(&settings)
+                {
+                    return Err(anyhow::anyhow!(error.to_string()));
                 }
                 Ok((
                     id.clone(),
@@ -716,24 +716,24 @@ 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() {
-                            let _ = tx.send(Ok(()));
-                        }
+                    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() {
-                            let _ = tx.send(Err("Context server stopped running".into()));
-                        }
+                    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() {
-                            let _ = tx.send(Err(error.clone()));
-                        }
+                    if server_id == &context_server_id
+                        && let Some(tx) = tx.lock().unwrap().take()
+                    {
+                        let _ = tx.send(Err(error.clone()));
                     }
                 }
                 _ => {}

crates/agent_ui/src/agent_configuration/tool_picker.rs πŸ”—

@@ -191,10 +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) {
-                                tools_by_provider.entry(server_id).or_default().push(name);
-                            }
+                        if let PickerItem::Tool { server_id, name } = item.clone()
+                            && name.contains(&query)
+                        {
+                            tools_by_provider.entry(server_id).or_default().push(name);
                         }
                     }
 

crates/agent_ui/src/agent_diff.rs πŸ”—

@@ -1043,18 +1043,18 @@ impl ToolbarItemView for AgentDiffToolbar {
                 return self.location(cx);
             }
 
-            if let Some(editor) = item.act_as::<Editor>(cx) {
-                if editor.read(cx).mode().is_full() {
-                    let agent_diff = AgentDiff::global(cx);
-
-                    self.active_item = Some(AgentDiffToolbarItem::Editor {
-                        editor: editor.downgrade(),
-                        state: agent_diff.read(cx).editor_state(&editor.downgrade()),
-                        _diff_subscription: cx.observe(&agent_diff, Self::handle_diff_notify),
-                    });
+            if let Some(editor) = item.act_as::<Editor>(cx)
+                && editor.read(cx).mode().is_full()
+            {
+                let agent_diff = AgentDiff::global(cx);
 
-                    return self.location(cx);
-                }
+                self.active_item = Some(AgentDiffToolbarItem::Editor {
+                    editor: editor.downgrade(),
+                    state: agent_diff.read(cx).editor_state(&editor.downgrade()),
+                    _diff_subscription: cx.observe(&agent_diff, Self::handle_diff_notify),
+                });
+
+                return self.location(cx);
             }
         }
 
@@ -1538,16 +1538,10 @@ impl AgentDiff {
     ) {
         match event {
             workspace::Event::ItemAdded { item } => {
-                if let Some(editor) = item.downcast::<Editor>() {
-                    if let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx) {
-                        self.register_editor(
-                            workspace.downgrade(),
-                            buffer.clone(),
-                            editor,
-                            window,
-                            cx,
-                        );
-                    }
+                if let Some(editor) = item.downcast::<Editor>()
+                    && let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx)
+                {
+                    self.register_editor(workspace.downgrade(), buffer.clone(), editor, window, cx);
                 }
             }
             _ => {}
@@ -1850,22 +1844,22 @@ 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() {
-                let changed_buffers = thread.action_log(cx).read(cx).changed_buffers(cx);
-
-                let mut keys = changed_buffers.keys().cycle();
-                keys.find(|k| *k == &curr_buffer);
-                let next_project_path = keys
-                    .next()
-                    .filter(|k| *k != &curr_buffer)
-                    .and_then(|after| after.read(cx).project_path(cx));
-
-                if let Some(path) = next_project_path {
-                    let task = workspace.open_path(path, None, true, window, cx);
-                    let task = cx.spawn(async move |_, _cx| task.await.map(|_| ()));
-                    return Some(task);
-                }
+        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();
+            keys.find(|k| *k == &curr_buffer);
+            let next_project_path = keys
+                .next()
+                .filter(|k| *k != &curr_buffer)
+                .and_then(|after| after.read(cx).project_path(cx));
+
+            if let Some(path) = next_project_path {
+                let task = workspace.open_path(path, None, true, window, cx);
+                let task = cx.spawn(async move |_, _cx| task.await.map(|_| ()));
+                return Some(task);
             }
         }
 

crates/agent_ui/src/agent_panel.rs πŸ”—

@@ -1398,14 +1398,13 @@ impl AgentPanel {
                 if LanguageModelRegistry::read_global(cx)
                     .default_model()
                     .map_or(true, |model| model.provider.id() != provider.id())
+                    && let Some(model) = provider.default_model(cx)
                 {
-                    if let Some(model) = provider.default_model(cx) {
-                        update_settings_file::<AgentSettings>(
-                            self.fs.clone(),
-                            cx,
-                            move |settings, _| settings.set_model(model),
-                        );
-                    }
+                    update_settings_file::<AgentSettings>(
+                        self.fs.clone(),
+                        cx,
+                        move |settings, _| settings.set_model(model),
+                    );
                 }
 
                 self.new_thread(&NewThread::default(), window, cx);

crates/agent_ui/src/buffer_codegen.rs πŸ”—

@@ -352,12 +352,12 @@ impl CodegenAlternative {
         event: &multi_buffer::Event,
         cx: &mut Context<Self>,
     ) {
-        if let multi_buffer::Event::TransactionUndone { transaction_id } = event {
-            if self.transformation_transaction_id == Some(*transaction_id) {
-                self.transformation_transaction_id = None;
-                self.generation = Task::ready(());
-                cx.emit(CodegenEvent::Undone);
-            }
+        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);
         }
     }
 
@@ -576,38 +576,34 @@ 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);
-                                            base_indent = base_indent.or(line_indent);
-
-                                            let line_indent = line_indent.unwrap();
-                                            let base_indent = base_indent.unwrap();
-                                            let indent_delta =
-                                                line_indent as i32 - base_indent as i32;
-                                            let mut corrected_indent_len = cmp::max(
-                                                0,
-                                                suggested_line_indent.len as i32 + indent_delta,
-                                            )
-                                                as usize;
-                                            if first_line {
-                                                corrected_indent_len = corrected_indent_len
-                                                    .saturating_sub(
-                                                        selection_start.column as usize,
-                                                    );
-                                            }
-
-                                            let indent_char = suggested_line_indent.char();
-                                            let mut indent_buffer = [0; 4];
-                                            let indent_str =
-                                                indent_char.encode_utf8(&mut indent_buffer);
-                                            new_text.replace_range(
-                                                ..line_indent,
-                                                &indent_str.repeat(corrected_indent_len),
-                                            );
+                                    {
+                                        line_indent = Some(non_whitespace_ch_ix);
+                                        base_indent = base_indent.or(line_indent);
+
+                                        let line_indent = line_indent.unwrap();
+                                        let base_indent = base_indent.unwrap();
+                                        let indent_delta = line_indent as i32 - base_indent as i32;
+                                        let mut corrected_indent_len = cmp::max(
+                                            0,
+                                            suggested_line_indent.len as i32 + indent_delta,
+                                        )
+                                            as usize;
+                                        if first_line {
+                                            corrected_indent_len = corrected_indent_len
+                                                .saturating_sub(selection_start.column as usize);
                                         }
+
+                                        let indent_char = suggested_line_indent.char();
+                                        let mut indent_buffer = [0; 4];
+                                        let indent_str =
+                                            indent_char.encode_utf8(&mut indent_buffer);
+                                        new_text.replace_range(
+                                            ..line_indent,
+                                            &indent_str.repeat(corrected_indent_len),
+                                        );
                                     }
 
                                     if line_indent.is_some() {

crates/agent_ui/src/context_strip.rs πŸ”—

@@ -368,10 +368,10 @@ impl ContextStrip {
         _window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(suggested) = self.suggested_context(cx) {
-            if self.is_suggested_focused(&self.added_contexts(cx)) {
-                self.add_suggested_context(&suggested, cx);
-            }
+        if let Some(suggested) = self.suggested_context(cx)
+            && self.is_suggested_focused(&self.added_contexts(cx))
+        {
+            self.add_suggested_context(&suggested, cx);
         }
     }
 

crates/agent_ui/src/inline_assistant.rs πŸ”—

@@ -182,13 +182,13 @@ 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::<Editor>(cx)) {
-                    if 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) {
-                                self.finish_assist(assist_id, false, window, cx)
-                            }
+                if let Some(editor) = item.upgrade().and_then(|item| item.act_as::<Editor>(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) {
+                            self.finish_assist(assist_id, false, window, cx)
                         }
                     }
                 }
@@ -342,13 +342,11 @@ impl InlineAssistant {
                         )
                         .await
                         .ok();
-                    if let Some(answer) = answer {
-                        if answer == 0 {
-                            cx.update(|window, cx| {
-                                window.dispatch_action(Box::new(OpenSettings), cx)
-                            })
+                    if let Some(answer) = answer
+                        && answer == 0
+                    {
+                        cx.update(|window, cx| window.dispatch_action(Box::new(OpenSettings), cx))
                             .ok();
-                        }
                     }
                     anyhow::Ok(())
                 })
@@ -435,11 +433,11 @@ impl InlineAssistant {
                 }
             }
 
-            if let Some(prev_selection) = selections.last_mut() {
-                if selection.start <= prev_selection.end {
-                    prev_selection.end = selection.end;
-                    continue;
-                }
+            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());
@@ -985,14 +983,13 @@ 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;
-                        }
+                    {
+                        return;
                     }
                 }
 
@@ -1503,20 +1500,18 @@ impl InlineAssistant {
         window: &mut Window,
         cx: &mut App,
     ) -> Option<InlineAssistTarget> {
-        if let Some(terminal_panel) = workspace.panel::<TerminalPanel>(cx) {
-            if terminal_panel
+        if let Some(terminal_panel) = workspace.panel::<TerminalPanel>(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| {
-                    pane.read(cx)
-                        .active_item()
-                        .and_then(|t| t.downcast::<TerminalView>())
-                }) {
-                    return Some(InlineAssistTarget::Terminal(terminal_view));
-                }
-            }
+            && let Some(terminal_view) = terminal_panel.read(cx).pane().and_then(|pane| {
+                pane.read(cx)
+                    .active_item()
+                    .and_then(|t| t.downcast::<TerminalView>())
+            })
+        {
+            return Some(InlineAssistTarget::Terminal(terminal_view));
         }
 
         let context_editor = agent_panel
@@ -1741,22 +1736,20 @@ 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() {
-                                        let error = format!("Inline assistant error: {}", error);
-                                        workspace.update(cx, |workspace, cx| {
-                                            struct InlineAssistantError;
-
-                                            let id =
-                                                NotificationId::composite::<InlineAssistantError>(
-                                                    assist_id.0,
-                                                );
-
-                                            workspace.show_toast(Toast::new(id, error), cx);
-                                        })
-                                    }
-                                }
+                            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;
+
+                                    let id = NotificationId::composite::<InlineAssistantError>(
+                                        assist_id.0,
+                                    );
+
+                                    workspace.show_toast(Toast::new(id, error), cx);
+                                })
                             }
 
                             if assist.decorations.is_none() {
@@ -1821,18 +1814,18 @@ 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() {
-                    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_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() {
-                    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)
+                && 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 {

crates/agent_ui/src/terminal_inline_assistant.rs πŸ”—

@@ -388,20 +388,20 @@ 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() {
-                assist
-                    .terminal
-                    .update(cx, |terminal, cx| {
-                        terminal.clear_block_below_cursor(cx);
-                        let block = terminal_view::BlockProperties {
-                            height,
-                            render: Box::new(move |_| prompt_editor.clone().into_any_element()),
-                        };
-                        terminal.set_block_below_cursor(block, window, cx);
-                    })
-                    .log_err();
-            }
+        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| {
+                    terminal.clear_block_below_cursor(cx);
+                    let block = terminal_view::BlockProperties {
+                        height,
+                        render: Box::new(move |_| prompt_editor.clone().into_any_element()),
+                    };
+                    terminal.set_block_below_cursor(block, window, cx);
+                })
+                .log_err();
         }
     }
 }
@@ -450,23 +450,20 @@ 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() {
-                                        let error =
-                                            format!("Terminal inline assistant error: {}", error);
-                                        workspace.update(cx, |workspace, cx| {
-                                            struct InlineAssistantError;
-
-                                            let id =
-                                                NotificationId::composite::<InlineAssistantError>(
-                                                    assist_id.0,
-                                                );
-
-                                            workspace.show_toast(Toast::new(id, error), cx);
-                                        })
-                                    }
-                                }
+                            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| {
+                                    struct InlineAssistantError;
+
+                                    let id = NotificationId::composite::<InlineAssistantError>(
+                                        assist_id.0,
+                                    );
+
+                                    workspace.show_toast(Toast::new(id, error), cx);
+                                })
                             }
 
                             if assist.prompt_editor.is_none() {

crates/agent_ui/src/text_thread_editor.rs πŸ”—

@@ -745,28 +745,27 @@ impl TextThreadEditor {
     ) {
         if let Some(invoked_slash_command) =
             self.context.read(cx).invoked_slash_command(&command_id)
+            && let InvokedSlashCommandStatus::Finished = invoked_slash_command.status
         {
-            if 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| {
-                        context.reparse(cx);
-                        context
-                            .pending_commands_for_range(range.clone(), cx)
-                            .to_vec()
-                    });
+            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| {
+                    context.reparse(cx);
+                    context
+                        .pending_commands_for_range(range.clone(), cx)
+                        .to_vec()
+                });
 
-                    for command in commands {
-                        self.run_command(
-                            command.source_range,
-                            &command.name,
-                            &command.arguments,
-                            false,
-                            self.workspace.clone(),
-                            window,
-                            cx,
-                        );
-                    }
+                for command in commands {
+                    self.run_command(
+                        command.source_range,
+                        &command.name,
+                        &command.arguments,
+                        false,
+                        self.workspace.clone(),
+                        window,
+                        cx,
+                    );
                 }
             }
         }

crates/agent_ui/src/thread_history.rs πŸ”—

@@ -166,14 +166,13 @@ 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);
-                            }
+                        {
+                            this.set_selected_entry_index(new_ix, cx);
                         }
                     }
                     SearchState::Searching { query, .. } | SearchState::Searched { query, .. } => {

crates/assistant_context/src/assistant_context.rs πŸ”—

@@ -1076,20 +1076,20 @@ impl AssistantContext {
                     timestamp,
                     ..
                 } => {
-                    if let Some(slash_command) = self.invoked_slash_commands.get_mut(&id) {
-                        if timestamp > slash_command.timestamp {
-                            slash_command.timestamp = timestamp;
-                            match error_message {
-                                Some(message) => {
-                                    slash_command.status =
-                                        InvokedSlashCommandStatus::Error(message.into());
-                                }
-                                None => {
-                                    slash_command.status = InvokedSlashCommandStatus::Finished;
-                                }
+                    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) => {
+                                slash_command.status =
+                                    InvokedSlashCommandStatus::Error(message.into());
+                            }
+                            None => {
+                                slash_command.status = InvokedSlashCommandStatus::Finished;
                             }
-                            cx.emit(ContextEvent::InvokedSlashCommandChanged { command_id: id });
                         }
+                        cx.emit(ContextEvent::InvokedSlashCommandChanged { command_id: id });
                     }
                 }
                 ContextOperation::BufferOperation(_) => unreachable!(),
@@ -1368,10 +1368,10 @@ impl AssistantContext {
                 continue;
             }
 
-            if let Some(last_anchor) = last_anchor {
-                if message.id == last_anchor {
-                    hit_last_anchor = true;
-                }
+            if let Some(last_anchor) = last_anchor
+                && message.id == last_anchor
+            {
+                hit_last_anchor = true;
             }
 
             new_anchor_needs_caching = new_anchor_needs_caching
@@ -1406,10 +1406,10 @@ impl AssistantContext {
         if !self.pending_completions.is_empty() {
             return;
         }
-        if let Some(cache_configuration) = cache_configuration {
-            if !cache_configuration.should_speculate {
-                return;
-            }
+        if let Some(cache_configuration) = cache_configuration
+            && !cache_configuration.should_speculate
+        {
+            return;
         }
 
         let request = {
@@ -1552,25 +1552,24 @@ impl AssistantContext {
                     })
                     .map(ToOwned::to_owned)
                     .collect::<SmallVec<_>>();
-                if let Some(command) = self.slash_commands.command(name, cx) {
-                    if !command.requires_argument() || !arguments.is_empty() {
-                        let start_ix = offset + command_line.name.start - 1;
-                        let end_ix = offset
-                            + command_line
-                                .arguments
-                                .last()
-                                .map_or(command_line.name.end, |argument| argument.end);
-                        let source_range =
-                            buffer.anchor_after(start_ix)..buffer.anchor_after(end_ix);
-                        let pending_command = ParsedSlashCommand {
-                            name: name.to_string(),
-                            arguments,
-                            source_range,
-                            status: PendingSlashCommandStatus::Idle,
-                        };
-                        updated.push(pending_command.clone());
-                        new_commands.push(pending_command);
-                    }
+                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
+                            .arguments
+                            .last()
+                            .map_or(command_line.name.end, |argument| argument.end);
+                    let source_range = buffer.anchor_after(start_ix)..buffer.anchor_after(end_ix);
+                    let pending_command = ParsedSlashCommand {
+                        name: name.to_string(),
+                        arguments,
+                        source_range,
+                        status: PendingSlashCommandStatus::Idle,
+                    };
+                    updated.push(pending_command.clone());
+                    new_commands.push(pending_command);
                 }
             }
 
@@ -1799,14 +1798,13 @@ 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);
-                                    }
+                                {
+                                    invoked_slash_command
+                                        .run_commands_in_ranges
+                                        .push(start..end);
                                 }
                             }
                             SlashCommandEvent::EndSection => {
@@ -2741,10 +2739,10 @@ impl AssistantContext {
                     }
 
                     this.read_with(cx, |this, _cx| {
-                        if let Some(summary) = this.summary.content() {
-                            if summary.text.is_empty() {
-                                bail!("Model generated an empty summary");
-                            }
+                        if let Some(summary) = this.summary.content()
+                            && summary.text.is_empty()
+                        {
+                            bail!("Model generated an empty summary");
                         }
                         Ok(())
                     })??;
@@ -2924,18 +2922,18 @@ 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() {
-                        fs.rename(
-                            old_path,
-                            &new_path,
-                            RenameOptions {
-                                overwrite: true,
-                                ignore_if_exists: true,
-                            },
-                        )
-                        .await?;
-                    }
+                if let Some(old_path) = old_path.as_ref()
+                    && new_path.as_path() != old_path.as_ref()
+                {
+                    fs.rename(
+                        old_path,
+                        &new_path,
+                        RenameOptions {
+                            overwrite: true,
+                            ignore_if_exists: true,
+                        },
+                    )
+                    .await?;
                 }
 
                 // update path before write in case it fails

crates/assistant_context/src/context_store.rs πŸ”—

@@ -894,34 +894,33 @@ 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::<context_server::types::requests::PromptsList>(())
                     .await
                     .log_err()
-                {
-                    let slash_command_ids = response
-                        .prompts
-                        .into_iter()
-                        .filter(assistant_slash_commands::acceptable_prompt)
-                        .map(|prompt| {
-                            log::info!("registering context server command: {:?}", prompt.name);
-                            slash_command_working_set.insert(Arc::new(
-                                assistant_slash_commands::ContextServerSlashCommand::new(
-                                    context_server_store.clone(),
-                                    server.id(),
-                                    prompt,
-                                ),
-                            ))
-                        })
-                        .collect::<Vec<_>>();
-
-                    this.update(cx, |this, _cx| {
-                        this.context_server_slash_command_ids
-                            .insert(server_id.clone(), slash_command_ids);
+            {
+                let slash_command_ids = response
+                    .prompts
+                    .into_iter()
+                    .filter(assistant_slash_commands::acceptable_prompt)
+                    .map(|prompt| {
+                        log::info!("registering context server command: {:?}", prompt.name);
+                        slash_command_working_set.insert(Arc::new(
+                            assistant_slash_commands::ContextServerSlashCommand::new(
+                                context_server_store.clone(),
+                                server.id(),
+                                prompt,
+                            ),
+                        ))
                     })
-                    .log_err();
-                }
+                    .collect::<Vec<_>>();
+
+                this.update(cx, |this, _cx| {
+                    this.context_server_slash_command_ids
+                        .insert(server_id.clone(), slash_command_ids);
+                })
+                .log_err();
             }
         })
         .detach();

crates/assistant_slash_commands/src/context_server_command.rs πŸ”—

@@ -39,10 +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() {
-                parts.push(arg.name.as_str());
-            }
+        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)
     }

crates/assistant_slash_commands/src/delta_command.rs πŸ”—

@@ -66,23 +66,22 @@ impl SlashCommand for DeltaSlashCommand {
                 .metadata
                 .as_ref()
                 .and_then(|value| serde_json::from_value::<FileCommandMetadata>(value.clone()).ok())
+                && paths.insert(metadata.path.clone())
             {
-                if paths.insert(metadata.path.clone()) {
-                    file_command_old_outputs.push(
-                        context_buffer
-                            .as_rope()
-                            .slice(section.range.to_offset(&context_buffer)),
-                    );
-                    file_command_new_outputs.push(Arc::new(FileSlashCommand).run(
-                        std::slice::from_ref(&metadata.path),
-                        context_slash_command_output_sections,
-                        context_buffer.clone(),
-                        workspace.clone(),
-                        delegate.clone(),
-                        window,
-                        cx,
-                    ));
-                }
+                file_command_old_outputs.push(
+                    context_buffer
+                        .as_rope()
+                        .slice(section.range.to_offset(&context_buffer)),
+                );
+                file_command_new_outputs.push(Arc::new(FileSlashCommand).run(
+                    std::slice::from_ref(&metadata.path),
+                    context_slash_command_output_sections,
+                    context_buffer.clone(),
+                    workspace.clone(),
+                    delegate.clone(),
+                    window,
+                    cx,
+                ));
             }
         }
 
@@ -95,25 +94,25 @@ 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() {
-                            let new_text = &new_output.text[file_command_range.range.clone()];
-                            if old_text.chars().ne(new_text.chars()) {
-                                changes_detected = true;
-                                output.sections.extend(new_output.sections.into_iter().map(
-                                    |section| SlashCommandOutputSection {
-                                        range: output.text.len() + section.range.start
-                                            ..output.text.len() + section.range.end,
-                                        icon: section.icon,
-                                        label: section.label,
-                                        metadata: section.metadata,
-                                    },
-                                ));
-                                output.text.push_str(&new_output.text);
-                            }
-                        }
+                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;
+                        output
+                            .sections
+                            .extend(new_output.sections.into_iter().map(|section| {
+                                SlashCommandOutputSection {
+                                    range: output.text.len() + section.range.start
+                                        ..output.text.len() + section.range.end,
+                                    icon: section.icon,
+                                    label: section.label,
+                                    metadata: section.metadata,
+                                }
+                            }));
+                        output.text.push_str(&new_output.text);
                     }
                 }
             }

crates/assistant_slash_commands/src/diagnostics_command.rs πŸ”—

@@ -280,10 +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) {
-                    continue;
-                }
+            if let Some(path_matcher) = &options.path_matcher
+                && !path_matcher.is_match(&path)
+            {
+                continue;
             }
 
             project_summary.error_count += summary.error_count;

crates/assistant_slash_commands/src/tab_command.rs πŸ”—

@@ -195,16 +195,14 @@ fn tab_items_for_queries(
                     }
 
                     for editor in workspace.items_of_type::<Editor>(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()) {
-                                    let snapshot = buffer.read(cx).snapshot();
-                                    let full_path = snapshot.resolve_file_path(cx, true);
-                                    open_buffers.push((full_path, snapshot, *timestamp));
-                                }
-                            }
+                            && 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));
                         }
                     }
 

crates/assistant_tool/src/tool_schema.rs πŸ”—

@@ -24,16 +24,16 @@ 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 !obj.contains_key("additionalProperties") {
-                obj.insert("additionalProperties".to_string(), Value::Bool(false));
-            }
+    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));
+        }
 
-            // OpenAI API requires non-missing `properties`
-            if !obj.contains_key("properties") {
-                obj.insert("properties".to_string(), Value::Object(Default::default()));
-            }
+        // OpenAI API requires non-missing `properties`
+        if !obj.contains_key("properties") {
+            obj.insert("properties".to_string(), Value::Object(Default::default()));
         }
     }
     Ok(())
@@ -59,10 +59,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) {
-                    obj.remove(key);
-                }
+            if let Some(value) = obj.get(key)
+                && predicate(value)
+            {
+                obj.remove(key);
             }
         }
 
@@ -77,12 +77,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() {
-                let subschemas_clone = subschemas.clone();
-                obj.remove("oneOf");
-                obj.insert("anyOf".to_string(), subschemas_clone);
-            }
+        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

crates/assistant_tools/src/edit_agent.rs πŸ”—

@@ -672,29 +672,30 @@ impl EditAgent {
         cx: &mut AsyncApp,
     ) -> Result<BoxStream<'static, Result<String, LanguageModelCompletionError>>> {
         let mut messages_iter = conversation.messages.iter_mut();
-        if let Some(last_message) = messages_iter.next_back() {
-            if last_message.role == Role::Assistant {
-                let old_content_len = last_message.content.len();
-                last_message
-                    .content
-                    .retain(|content| !matches!(content, MessageContent::ToolUse(_)));
-                let new_content_len = last_message.content.len();
-
-                // We just removed pending tool uses from the content of the
-                // last message, so it doesn't make sense to cache it anymore
-                // (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() {
-                        last_message.cache = false;
-                        prev_message.cache = true;
-                    }
-                }
+        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
+                .retain(|content| !matches!(content, MessageContent::ToolUse(_)));
+            let new_content_len = last_message.content.len();
+
+            // We just removed pending tool uses from the content of the
+            // last message, so it doesn't make sense to cache it anymore
+            // (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
+                && 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();
-                }
+            if last_message.content.is_empty() {
+                conversation.messages.pop();
             }
         }
 

crates/assistant_tools/src/edit_agent/evals.rs πŸ”—

@@ -1283,14 +1283,14 @@ impl EvalAssertion {
 
             // Parse the score from the response
             let re = regex::Regex::new(r"<score>(\d+)</score>").unwrap();
-            if let Some(captures) = re.captures(&output) {
-                if let Some(score_match) = captures.get(1) {
-                    let score = score_match.as_str().parse().unwrap_or(0);
-                    return Ok(EvalAssertionOutcome {
-                        score,
-                        message: Some(output),
-                    });
-                }
+            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}");

crates/assistant_tools/src/edit_file_tool.rs πŸ”—

@@ -155,10 +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()) {
-                return true;
-            }
+        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
@@ -199,10 +199,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()) {
-                        description.push_str(" (global settings)");
-                    }
+                } else if let Ok(canonical_path) = std::fs::canonicalize(&input.path)
+                    && canonical_path.starts_with(paths::config_dir())
+                {
+                    description.push_str(" (global settings)");
                 }
 
                 description

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;
                 }

crates/assistant_tools/src/schema.rs πŸ”—

@@ -43,12 +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<T>, 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() {
-                    *type_field = first_type.clone();
-                }
-            }
+        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

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) };

crates/breadcrumbs/src/breadcrumbs.rs πŸ”—

@@ -82,11 +82,12 @@ 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)
-                {
-                    return styled_element;
-                }
+            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', "⏎"))

crates/buffer_diff/src/buffer_diff.rs πŸ”—

@@ -572,14 +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;
-                        }
+                        )
+                    {
+                        has_pending = true;
+                        secondary_status = pending_hunk.new_status;
                     }
                 }
 
@@ -1036,16 +1036,15 @@ 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 {
-                    range.start = secondary_hunk_range.start.min(&range.start, buffer);
-                    range.end = secondary_hunk_range.end.max(&range.end, buffer);
-                } else {
-                    changed_range = Some(secondary_hunk_range);
-                }
+        {
+            if let Some(range) = &mut changed_range {
+                range.start = secondary_hunk_range.start.min(&range.start, buffer);
+                range.end = secondary_hunk_range.end.max(&range.end, buffer);
+            } else {
+                changed_range = Some(secondary_hunk_range);
             }
         }
 

crates/call/src/call_impl/room.rs πŸ”—

@@ -827,24 +827,23 @@ 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
+                                    livekit_participant.track_publications().into_values()
                                 {
-                                    for publication in
-                                        livekit_participant.track_publications().into_values()
-                                    {
-                                        if let Some(track) = publication.track() {
-                                            this.livekit_room_updated(
-                                                RoomEvent::TrackSubscribed {
-                                                    track,
-                                                    publication,
-                                                    participant: livekit_participant.clone(),
-                                                },
-                                                cx,
-                                            )
-                                            .warn_on_err();
-                                        }
+                                    if let Some(track) = publication.track() {
+                                        this.livekit_room_updated(
+                                            RoomEvent::TrackSubscribed {
+                                                track,
+                                                publication,
+                                                participant: livekit_participant.clone(),
+                                            },
+                                            cx,
+                                        )
+                                        .warn_on_err();
                                     }
                                 }
                             }
@@ -940,10 +939,9 @@ impl Room {
                                 self.client.user_id()
                             )
                         })?;
-                if self.live_kit.as_ref().map_or(true, |kit| kit.deafened) {
-                    if publication.is_audio() {
-                        publication.set_enabled(false, cx);
-                    }
+                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) => {
@@ -1005,10 +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 {
-                        room.speaking = speaker_ids.binary_search(&id).is_ok();
-                    }
+                if let Some(id) = self.client.user_id()
+                    && let Some(room) = &mut self.live_kit
+                {
+                    room.speaking = speaker_ids.binary_search(&id).is_ok();
                 }
             }
 
@@ -1042,18 +1040,16 @@ impl Room {
                     if let LocalTrack::Published {
                         track_publication, ..
                     } = &room.microphone_track
+                        && track_publication.sid() == publication.sid()
                     {
-                        if track_publication.sid() == publication.sid() {
-                            room.microphone_track = LocalTrack::None;
-                        }
+                        room.microphone_track = LocalTrack::None;
                     }
                     if let LocalTrack::Published {
                         track_publication, ..
                     } = &room.screen_track
+                        && track_publication.sid() == publication.sid()
                     {
-                        if track_publication.sid() == publication.sid() {
-                            room.screen_track = LocalTrack::None;
-                        }
+                        room.screen_track = LocalTrack::None;
                     }
                 }
             }
@@ -1484,10 +1480,8 @@ impl Room {
 
             self.set_deafened(deafened, cx);
 
-            if should_change_mute {
-                if let Some(task) = self.set_mute(deafened, cx) {
-                    task.detach_and_log_err(cx);
-                }
+            if should_change_mute && let Some(task) = self.set_mute(deafened, cx) {
+                task.detach_and_log_err(cx);
             }
         }
     }

crates/channel/src/channel_buffer.rs πŸ”—

@@ -191,12 +191,11 @@ impl ChannelBuffer {
                 operation,
                 is_local: true,
             } => {
-                if *ZED_ALWAYS_ACTIVE {
-                    if let language::Operation::UpdateSelections { selections, .. } = operation {
-                        if selections.is_empty() {
-                            return;
-                        }
-                    }
+                if *ZED_ALWAYS_ACTIVE
+                    && let language::Operation::UpdateSelections { selections, .. } = operation
+                    && selections.is_empty()
+                {
+                    return;
                 }
                 let operation = language::proto::serialize_operation(operation);
                 self.client

crates/channel/src/channel_chat.rs πŸ”—

@@ -329,24 +329,24 @@ 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 {
-                            let mut cursor = chat
-                                .messages
-                                .cursor::<Dimensions<ChannelMessageId, Count>>(&());
-                            let message_id = ChannelMessageId::Saved(message_id);
-                            cursor.seek(&message_id, Bias::Left);
-                            return ControlFlow::Break(
-                                if cursor
-                                    .item()
-                                    .map_or(false, |message| message.id == message_id)
-                                {
-                                    Some(cursor.start().1.0)
-                                } else {
-                                    None
-                                },
-                            );
-                        }
+                    if let Some(first_id) = chat.first_loaded_message_id()
+                        && first_id <= message_id
+                    {
+                        let mut cursor = chat
+                            .messages
+                            .cursor::<Dimensions<ChannelMessageId, Count>>(&());
+                        let message_id = ChannelMessageId::Saved(message_id);
+                        cursor.seek(&message_id, Bias::Left);
+                        return ControlFlow::Break(
+                            if cursor
+                                .item()
+                                .map_or(false, |message| message.id == message_id)
+                            {
+                                Some(cursor.start().1.0)
+                            } else {
+                                None
+                            },
+                        );
                     }
                     ControlFlow::Continue(chat.load_more_messages(cx))
                 })
@@ -359,22 +359,21 @@ impl ChannelChat {
     }
 
     pub fn acknowledge_last_message(&mut self, cx: &mut Context<Self>) {
-        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)
-            {
-                self.rpc
-                    .send(proto::AckChannelMessage {
-                        channel_id: self.channel_id.0,
-                        message_id: latest_message_id,
-                    })
-                    .ok();
-                self.last_acknowledged_id = Some(latest_message_id);
-                self.channel_store.update(cx, |store, cx| {
-                    store.acknowledge_message_id(self.channel_id, latest_message_id, cx);
-                });
-            }
+        {
+            self.rpc
+                .send(proto::AckChannelMessage {
+                    channel_id: self.channel_id.0,
+                    message_id: latest_message_id,
+                })
+                .ok();
+            self.last_acknowledged_id = Some(latest_message_id);
+            self.channel_store.update(cx, |store, cx| {
+                store.acknowledge_message_id(self.channel_id, latest_message_id, cx);
+            });
         }
     }
 
@@ -407,10 +406,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) {
-                        return Some(ancestor_id);
-                    }
+                if let Some(ancestor_id) = message.reply_to_message_id
+                    && !loaded_message_ids.contains(&ancestor_id)
+                {
+                    return Some(ancestor_id);
                 }
                 None
             })
@@ -646,32 +645,32 @@ impl ChannelChat {
     fn message_removed(&mut self, id: u64, cx: &mut Context<Self>) {
         let mut cursor = self.messages.cursor::<ChannelMessageId>(&());
         let mut messages = cursor.slice(&ChannelMessageId::Saved(id), Bias::Left);
-        if let Some(item) = cursor.item() {
-            if item.id == ChannelMessageId::Saved(id) {
-                let deleted_message_ix = messages.summary().count;
-                cursor.next();
-                messages.append(cursor.suffix(), &());
-                drop(cursor);
-                self.messages = messages;
-
-                // If the message that was deleted was the last acknowledged message,
-                // replace the acknowledged message with an earlier one.
-                self.channel_store.update(cx, |store, _| {
-                    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 {
-                            store.set_acknowledged_message_id(self.channel_id, Some(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(), &());
+            drop(cursor);
+            self.messages = messages;
+
+            // If the message that was deleted was the last acknowledged message,
+            // replace the acknowledged message with an earlier one.
+            self.channel_store.update(cx, |store, _| {
+                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
+                    && let ChannelMessageId::Saved(id) = summary.max_id
+                {
+                    store.set_acknowledged_message_id(self.channel_id, Some(id));
+                }
+            });
 
-                cx.emit(ChannelChatEvent::MessagesUpdated {
-                    old_range: deleted_message_ix..deleted_message_ix + 1,
-                    new_count: 0,
-                });
-            }
+            cx.emit(ChannelChatEvent::MessagesUpdated {
+                old_range: deleted_message_ix..deleted_message_ix + 1,
+                new_count: 0,
+            });
         }
     }
 

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,10 +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 {
-                return buffer.upgrade().is_some();
-            }
+        if let Some(buffer) = self.opened_buffers.get(&channel_id)
+            && let OpenEntityHandle::Open(buffer) = buffer
+        {
+            return buffer.upgrade().is_some();
         }
         false
     }
@@ -408,13 +407,12 @@ impl ChannelStore {
 
     pub fn last_acknowledge_message_id(&self, channel_id: ChannelId) -> Option<u64> {
         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();
-                }
+            {
+                return state.last_acknowledged_message_id();
             }
 
             None
@@ -962,27 +960,27 @@ 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() {
-                    chat.update(cx, |chat, cx| {
-                        chat.rejoin(cx);
-                    });
-                }
+            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() {
-                    let channel_buffer = buffer.read(cx);
-                    let buffer = channel_buffer.buffer().read(cx);
-                    buffer_versions.push(proto::ChannelBufferVersion {
-                        channel_id: channel_buffer.channel_id.0,
-                        epoch: channel_buffer.epoch(),
-                        version: language::proto::serialize_version(&buffer.version()),
-                    });
-                }
+            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 {
+                    channel_id: channel_buffer.channel_id.0,
+                    epoch: channel_buffer.epoch(),
+                    version: language::proto::serialize_version(&buffer.version()),
+                });
             }
         }
 
@@ -1078,10 +1076,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() {
-                                    buffer.update(cx, |buffer, cx| buffer.disconnect(cx));
-                                }
+                            if let OpenEntityHandle::Open(buffer) = &buffer
+                                && let Some(buffer) = buffer.upgrade()
+                            {
+                                buffer.update(cx, |buffer, cx| buffer.disconnect(cx));
                             }
                         }
                     })
@@ -1157,10 +1155,9 @@ impl ChannelStore {
                     }
                     if let Some(OpenEntityHandle::Open(buffer)) =
                         self.opened_buffers.remove(&channel_id)
+                        && let Some(buffer) = buffer.upgrade()
                     {
-                        if let Some(buffer) = buffer.upgrade() {
-                            buffer.update(cx, ChannelBuffer::disconnect);
-                        }
+                        buffer.update(cx, ChannelBuffer::disconnect);
                     }
                 }
             }
@@ -1170,12 +1167,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() {
-                            buffer.update(cx, ChannelBuffer::channel_changed);
-                        }
-                    }
+                if channel_changed
+                    && let Some(OpenEntityHandle::Open(buffer)) = self.opened_buffers.get(&id)
+                    && let Some(buffer) = buffer.upgrade()
+                {
+                    buffer.update(cx, ChannelBuffer::channel_changed);
                 }
             }
 

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
     }

crates/client/src/client.rs πŸ”—

@@ -864,22 +864,23 @@ 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? {
-                credentials = Some(old_credentials);
-            }
+        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 self.validate_credentials(&stored_credentials, cx).await? {
-                    credentials = Some(stored_credentials);
-                } else {
-                    self.credentials_provider
-                        .delete_credentials(cx)
-                        .await
-                        .log_err();
-                }
+        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 {
+                self.credentials_provider
+                    .delete_credentials(cx)
+                    .await
+                    .log_err();
             }
         }
 

crates/client/src/user.rs πŸ”—

@@ -894,10 +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 {
-                    self.by_github_login.remove(&old.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);

crates/collab/src/api/events.rs πŸ”—

@@ -149,35 +149,35 @@ 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() {
-            let properties = json!({
-                "app_version": report.header.app_version,
-                "os_version": report.header.os_version,
-                "os_name": "macOS",
-                "bundle_id": report.header.bundle_id,
-                "incident_id": report.header.incident_id,
-                "installation_id": installation_id,
-                "description": description,
-                "backtrace": summary,
-            });
-            let row = SnowflakeRow::new(
-                "Crash Reported",
-                None,
-                false,
-                Some(installation_id),
-                properties,
-            );
-            let data = serde_json::to_vec(&row)?;
-            kinesis_client
-                .put_record()
-                .stream_name(stream)
-                .partition_key(row.insert_id.unwrap_or_default())
-                .data(data.into())
-                .send()
-                .await
-                .log_err();
-        }
+    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,
+            "os_name": "macOS",
+            "bundle_id": report.header.bundle_id,
+            "incident_id": report.header.incident_id,
+            "installation_id": installation_id,
+            "description": description,
+            "backtrace": summary,
+        });
+        let row = SnowflakeRow::new(
+            "Crash Reported",
+            None,
+            false,
+            Some(installation_id),
+            properties,
+        );
+        let data = serde_json::to_vec(&row)?;
+        kinesis_client
+            .put_record()
+            .stream_name(stream)
+            .partition_key(row.insert_id.unwrap_or_default())
+            .data(data.into())
+            .send()
+            .await
+            .log_err();
     }
 
     if let Some(slack_panics_webhook) = app.config.slack_panics_webhook.clone() {
@@ -359,34 +359,34 @@ 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() {
-            let properties = json!({
-                "app_version": panic.app_version,
-                "os_name": panic.os_name,
-                "os_version": panic.os_version,
-                "incident_id": incident_id,
-                "installation_id": panic.installation_id,
-                "description": panic.payload,
-                "backtrace": backtrace,
-            });
-            let row = SnowflakeRow::new(
-                "Panic Reported",
-                None,
-                false,
-                panic.installation_id.clone(),
-                properties,
-            );
-            let data = serde_json::to_vec(&row)?;
-            kinesis_client
-                .put_record()
-                .stream_name(stream)
-                .partition_key(row.insert_id.unwrap_or_default())
-                .data(data.into())
-                .send()
-                .await
-                .log_err();
-        }
+    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,
+            "os_version": panic.os_version,
+            "incident_id": incident_id,
+            "installation_id": panic.installation_id,
+            "description": panic.payload,
+            "backtrace": backtrace,
+        });
+        let row = SnowflakeRow::new(
+            "Panic Reported",
+            None,
+            false,
+            panic.installation_id.clone(),
+            properties,
+        );
+        let data = serde_json::to_vec(&row)?;
+        kinesis_client
+            .put_record()
+            .stream_name(stream)
+            .partition_key(row.insert_id.unwrap_or_default())
+            .data(data.into())
+            .send()
+            .await
+            .log_err();
     }
 
     if !report_to_slack(&panic) {
@@ -518,31 +518,31 @@ 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() {
-            let mut request = kinesis_client.put_records().stream_name(stream);
-            let mut has_records = false;
-            for row in for_snowflake(
-                request_body.clone(),
-                first_event_at,
-                country_code.clone(),
-                checksum_matched,
-            ) {
-                if let Some(data) = serde_json::to_vec(&row).log_err() {
-                    request = request.records(
-                        aws_sdk_kinesis::types::PutRecordsRequestEntry::builder()
-                            .partition_key(request_body.system_id.clone().unwrap_or_default())
-                            .data(data.into())
-                            .build()
-                            .unwrap(),
-                    );
-                    has_records = true;
-                }
-            }
-            if has_records {
-                request.send().await.log_err();
+    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(
+            request_body.clone(),
+            first_event_at,
+            country_code.clone(),
+            checksum_matched,
+        ) {
+            if let Some(data) = serde_json::to_vec(&row).log_err() {
+                request = request.records(
+                    aws_sdk_kinesis::types::PutRecordsRequestEntry::builder()
+                        .partition_key(request_body.system_id.clone().unwrap_or_default())
+                        .data(data.into())
+                        .build()
+                        .unwrap(),
+                );
+                has_records = true;
             }
         }
+        if has_records {
+            request.send().await.log_err();
+        }
     };
 
     Ok(())

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,
@@ -346,12 +345,11 @@ async fn fetch_extensions_from_blob_store(
                 )
                 .await
                 .log_err()
-                {
-                    new_versions
-                        .entry(extension_id)
-                        .or_default()
-                        .push(extension);
-                }
+            {
+                new_versions
+                    .entry(extension_id)
+                    .or_default()
+                    .push(extension);
             }
         }
     }

crates/collab/src/auth.rs πŸ”—

@@ -79,27 +79,27 @@ pub async fn validate_header<B>(mut req: Request<B>, next: Next<B>) -> impl Into
         verify_access_token(access_token, user_id, &state.db).await
     };
 
-    if let Ok(validate_result) = validate_result {
-        if validate_result.is_valid {
-            let user = state
+    if let Ok(validate_result) = validate_result
+        && validate_result.is_valid
+    {
+        let user = state
+            .db
+            .get_user_by_id(user_id)
+            .await?
+            .with_context(|| format!("user {user_id} not found"))?;
+
+        if let Some(impersonator_id) = validate_result.impersonator_id {
+            let admin = state
                 .db
-                .get_user_by_id(user_id)
+                .get_user_by_id(impersonator_id)
                 .await?
-                .with_context(|| format!("user {user_id} not found"))?;
-
-            if let Some(impersonator_id) = validate_result.impersonator_id {
-                let admin = state
-                    .db
-                    .get_user_by_id(impersonator_id)
-                    .await?
-                    .with_context(|| format!("user {impersonator_id} not found"))?;
-                req.extensions_mut()
-                    .insert(Principal::Impersonated { user, admin });
-            } else {
-                req.extensions_mut().insert(Principal::User(user));
-            };
-            return Ok::<_, Error>(next.run(req).await);
-        }
+                .with_context(|| format!("user {impersonator_id} not found"))?;
+            req.extensions_mut()
+                .insert(Principal::Impersonated { user, admin });
+        } else {
+            req.extensions_mut().insert(Principal::User(user));
+        };
+        return Ok::<_, Error>(next.run(req).await);
     }
 
     Err(Error::http(

crates/collab/src/db/queries/extensions.rs πŸ”—

@@ -87,10 +87,10 @@ impl Database {
                 continue;
             };
 
-            if let Some((_, max_extension_version)) = &max_versions.get(&version.extension_id) {
-                if max_extension_version > &extension_version {
-                    continue;
-                }
+            if let Some((_, max_extension_version)) = &max_versions.get(&version.extension_id)
+                && max_extension_version > &extension_version
+            {
+                continue;
             }
 
             if let Some(constraints) = constraints {
@@ -331,10 +331,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 {
-                        continue;
-                    }
+                if let Ok(db_version) = semver::Version::parse(&extension.latest_version)
+                    && db_version >= latest_version.version
+                {
+                    continue;
                 }
 
                 let mut extension = extension.into_active_model();

crates/collab/src/db/queries/projects.rs πŸ”—

@@ -1321,10 +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 {
-                connection_ids.insert(host_connection);
-            }
+        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 {

crates/collab/src/rpc.rs πŸ”—

@@ -616,10 +616,10 @@ impl Server {
                             }
                         }
 
-                        if let Some(live_kit) = livekit_client.as_ref() {
-                            if delete_livekit_room {
-                                live_kit.delete_room(livekit_room).await.trace_err();
-                            }
+                        if let Some(live_kit) = livekit_client.as_ref()
+                            && delete_livekit_room
+                        {
+                            live_kit.delete_room(livekit_room).await.trace_err();
                         }
                     }
                 }
@@ -1015,47 +1015,47 @@ 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 {
-                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) {
-                    self.peer.send(
-                        connection_id,
-                        proto::UpdateContacts {
-                            contacts: vec![invitee_contact.clone()],
-                            ..Default::default()
-                        },
-                    )?;
-                    self.peer.send(
-                        connection_id,
-                        proto::UpdateInviteInfo {
-                            url: format!("{}{}", self.app_state.config.invite_link_prefix, &code),
-                            count: user.invite_count as u32,
-                        },
-                    )?;
-                }
+        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) {
+                self.peer.send(
+                    connection_id,
+                    proto::UpdateContacts {
+                        contacts: vec![invitee_contact.clone()],
+                        ..Default::default()
+                    },
+                )?;
+                self.peer.send(
+                    connection_id,
+                    proto::UpdateInviteInfo {
+                        url: format!("{}{}", self.app_state.config.invite_link_prefix, &code),
+                        count: user.invite_count as u32,
+                    },
+                )?;
             }
         }
         Ok(())
     }
 
     pub async fn invite_count_updated(self: &Arc<Self>, 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 {
-                let pool = self.connection_pool.lock();
-                for connection_id in pool.user_connection_ids(user_id) {
-                    self.peer.send(
-                        connection_id,
-                        proto::UpdateInviteInfo {
-                            url: format!(
-                                "{}{}",
-                                self.app_state.config.invite_link_prefix, invite_code
-                            ),
-                            count: user.invite_count as u32,
-                        },
-                    )?;
-                }
+        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(
+                    connection_id,
+                    proto::UpdateInviteInfo {
+                        url: format!(
+                            "{}{}",
+                            self.app_state.config.invite_link_prefix, invite_code
+                        ),
+                        count: user.invite_count as u32,
+                    },
+                )?;
             }
         }
         Ok(())
@@ -1101,10 +1101,10 @@ fn broadcast<F>(
     F: FnMut(ConnectionId) -> anyhow::Result<()>,
 {
     for receiver_id in receiver_ids {
-        if Some(receiver_id) != sender_id {
-            if let Err(error) = f(receiver_id) {
-                tracing::error!("failed to send to {:?} {}", receiver_id, error);
-            }
+        if Some(receiver_id) != sender_id
+            && let Err(error) = f(receiver_id)
+        {
+            tracing::error!("failed to send to {:?} {}", receiver_id, error);
         }
     }
 }
@@ -2294,11 +2294,10 @@ async fn update_language_server(
     let db = session.db().await;
 
     if let Some(proto::update_language_server::Variant::MetadataUpdated(update)) = &request.variant
+        && let Some(capabilities) = update.capabilities.clone()
     {
-        if let Some(capabilities) = update.capabilities.clone() {
-            db.update_server_capabilities(project_id, request.language_server_id, capabilities)
-                .await?;
-        }
+        db.update_server_capabilities(project_id, request.language_server_id, capabilities)
+            .await?;
     }
 
     let project_connection_ids = db

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);

crates/collab/src/tests/randomized_test_helpers.rs πŸ”—

@@ -198,11 +198,11 @@ pub async fn run_randomized_test<T: RandomizedTest>(
 }
 
 pub fn save_randomized_test_plan() {
-    if let Some(serialize_plan) = LAST_PLAN.lock().take() {
-        if let Some(path) = plan_save_path() {
-            eprintln!("saved test plan to path {:?}", path);
-            std::fs::write(path, serialize_plan()).unwrap();
-        }
+    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();
     }
 }
 
@@ -290,10 +290,9 @@ impl<T: RandomizedTest> TestPlan<T> {
                         if let StoredOperation::Client {
                             user_id, batch_id, ..
                         } = operation
+                            && batch_id == current_batch_id
                         {
-                            if batch_id == current_batch_id {
-                                return Some(user_id);
-                            }
+                            return Some(user_id);
                         }
                         None
                     }));
@@ -366,10 +365,9 @@ impl<T: RandomizedTest> TestPlan<T> {
                     },
                     applied,
                 ) = stored_operation
+                    && user_id == &current_user_id
                 {
-                    if user_id == &current_user_id {
-                        return Some((operation.clone(), applied.clone()));
-                    }
+                    return Some((operation.clone(), applied.clone()));
                 }
             }
             None
@@ -550,11 +548,11 @@ impl<T: RandomizedTest> TestPlan<T> {
                         .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 {
-                                assert!(!pool.is_user_online(user_id));
-                                assert!(!busy);
-                            }
+                        if let db::Contact::Accepted { user_id, busy, .. } = contact
+                            && user_id == removed_user_id
+                        {
+                            assert!(!pool.is_user_online(user_id));
+                            assert!(!busy);
                         }
                     }
                 }

crates/collab/src/user_backfiller.rs πŸ”—

@@ -130,17 +130,17 @@ impl UserBackfiller {
             .and_then(|value| value.parse::<i64>().ok())
             .and_then(|value| DateTime::from_timestamp(value, 0));
 
-        if rate_limit_remaining == Some(0) {
-            if let Some(reset_at) = rate_limit_reset {
-                let now = Utc::now();
-                if reset_at > now {
-                    let sleep_duration = reset_at - now;
-                    log::info!(
-                        "rate limit reached. Sleeping for {} seconds",
-                        sleep_duration.num_seconds()
-                    );
-                    self.executor.sleep(sleep_duration.to_std().unwrap()).await;
-                }
+        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;
+                log::info!(
+                    "rate limit reached. Sleeping for {} seconds",
+                    sleep_duration.num_seconds()
+                );
+                self.executor.sleep(sleep_duration.to_std().unwrap()).await;
             }
         }
 

crates/collab_ui/src/channel_view.rs πŸ”—

@@ -107,43 +107,32 @@ 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(link_position) = link_position {
-                            existing_view.update(cx, |channel_view, cx| {
-                                channel_view.focus_position_from_link(
-                                    link_position,
-                                    true,
-                                    window,
-                                    cx,
-                                )
-                            });
-                        }
-                        return existing_view;
+                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| {
+                            channel_view.focus_position_from_link(link_position, true, window, cx)
+                        });
                     }
+                    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) {
-                        pane.close_item_by_id(
-                            existing_item.entity_id(),
-                            SaveIntent::Skip,
-                            window,
-                            cx,
-                        )
+                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, window, cx)
                         .detach();
-                        pane.add_item(
-                            Box::new(channel_view.clone()),
-                            true,
-                            true,
-                            Some(ix),
-                            window,
-                            cx,
-                        );
-                    }
+                    pane.add_item(
+                        Box::new(channel_view.clone()),
+                        true,
+                        true,
+                        Some(ix),
+                        window,
+                        cx,
+                    );
                 }
 
                 if let Some(link_position) = link_position {
@@ -259,26 +248,21 @@ 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)
-            {
-                self.editor.update(cx, |editor, cx| {
-                    editor.change_selections(
-                        SelectionEffects::scroll(Autoscroll::focused()),
-                        window,
-                        cx,
-                        |s| {
-                            s.replace_cursors_with(|map| {
-                                vec![item.range.start.to_display_point(map)]
-                            })
-                        },
-                    )
-                });
-                return;
-            }
+        {
+            self.editor.update(cx, |editor, cx| {
+                editor.change_selections(
+                    SelectionEffects::scroll(Autoscroll::focused()),
+                    window,
+                    cx,
+                    |s| s.replace_cursors_with(|map| vec![item.range.start.to_display_point(map)]),
+                )
+            });
+            return;
         }
 
         if !first_attempt {

crates/collab_ui/src/chat_panel.rs πŸ”—

@@ -287,19 +287,20 @@ impl ChatPanel {
     }
 
     fn acknowledge_last_message(&mut self, cx: &mut Context<Self>) {
-        if self.active && self.is_scrolled_to_bottom {
-            if let Some((chat, _)) = &self.active_chat {
-                if let Some(channel_id) = self.channel_id(cx) {
-                    self.last_acknowledged_message_id = self
-                        .channel_store
-                        .read(cx)
-                        .last_acknowledge_message_id(channel_id);
-                }
-
-                chat.update(cx, |chat, cx| {
-                    chat.acknowledge_last_message(cx);
-                });
+        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
+                    .read(cx)
+                    .last_acknowledge_message_id(channel_id);
             }
+
+            chat.update(cx, |chat, cx| {
+                chat.acknowledge_last_message(cx);
+            });
         }
     }
 
@@ -405,14 +406,13 @@ 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);
-                    }
+                {
+                    active_chat.acknowledge_message(id);
                 }
 
                 (this_message, is_continuation_from_previous, is_admin)
@@ -871,34 +871,33 @@ 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
-                {
-                    this.update(cx, |this, cx| {
-                        if let Some(highlight_message_id) = highlight_message_id {
-                            let task = cx.spawn(async move |this, cx| {
-                                cx.background_executor().timer(Duration::from_secs(2)).await;
-                                this.update(cx, |this, cx| {
-                                    this.highlighted_message.take();
-                                    cx.notify();
-                                })
-                                .ok();
-                            });
-
-                            this.highlighted_message = Some((highlight_message_id, task));
-                        }
+            {
+                this.update(cx, |this, cx| {
+                    if let Some(highlight_message_id) = highlight_message_id {
+                        let task = cx.spawn(async move |this, cx| {
+                            cx.background_executor().timer(Duration::from_secs(2)).await;
+                            this.update(cx, |this, cx| {
+                                this.highlighted_message.take();
+                                cx.notify();
+                            })
+                            .ok();
+                        });
 
-                        if this.active_chat.as_ref().map_or(false, |(c, _)| *c == chat) {
-                            this.message_list.scroll_to(ListOffset {
-                                item_ix,
-                                offset_in_item: px(0.0),
-                            });
-                            cx.notify();
-                        }
-                    })?;
-                }
+                        this.highlighted_message = Some((highlight_message_id, task));
+                    }
+
+                    if this.active_chat.as_ref().map_or(false, |(c, _)| *c == chat) {
+                        this.message_list.scroll_to(ListOffset {
+                            item_ix,
+                            offset_in_item: px(0.0),
+                        });
+                        cx.notify();
+                    }
+                })?;
             }
 
             Ok(())

crates/collab_ui/src/chat_panel/message_editor.rs πŸ”—

@@ -241,38 +241,36 @@ impl MessageEditor {
     ) -> Task<Result<Vec<CompletionResponse>>> {
         if let Some((start_anchor, query, candidates)) =
             self.collect_mention_candidates(buffer, end_anchor, cx)
+            && !candidates.is_empty()
         {
-            if !candidates.is_empty() {
-                return cx.spawn(async move |_, cx| {
-                    let completion_response = Self::completions_for_candidates(
-                        cx,
-                        query.as_str(),
-                        &candidates,
-                        start_anchor..end_anchor,
-                        Self::completion_for_mention,
-                    )
-                    .await;
-                    Ok(vec![completion_response])
-                });
-            }
+            return cx.spawn(async move |_, cx| {
+                let completion_response = Self::completions_for_candidates(
+                    cx,
+                    query.as_str(),
+                    &candidates,
+                    start_anchor..end_anchor,
+                    Self::completion_for_mention,
+                )
+                .await;
+                Ok(vec![completion_response])
+            });
         }
 
         if let Some((start_anchor, query, candidates)) =
             self.collect_emoji_candidates(buffer, end_anchor, cx)
+            && !candidates.is_empty()
         {
-            if !candidates.is_empty() {
-                return cx.spawn(async move |_, cx| {
-                    let completion_response = Self::completions_for_candidates(
-                        cx,
-                        query.as_str(),
-                        candidates,
-                        start_anchor..end_anchor,
-                        Self::completion_for_emoji,
-                    )
-                    .await;
-                    Ok(vec![completion_response])
-                });
-            }
+            return cx.spawn(async move |_, cx| {
+                let completion_response = Self::completions_for_candidates(
+                    cx,
+                    query.as_str(),
+                    candidates,
+                    start_anchor..end_anchor,
+                    Self::completion_for_emoji,
+                )
+                .await;
+                Ok(vec![completion_response])
+            });
         }
 
         Task::ready(Ok(vec![CompletionResponse {
@@ -474,18 +472,17 @@ 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)
-                        {
-                            let start = multi_buffer.anchor_after(range.start);
-                            let end = multi_buffer.anchor_after(range.end);
+                    {
+                        let start = multi_buffer.anchor_after(range.start);
+                        let end = multi_buffer.anchor_after(range.end);
 
-                            mentioned_user_ids.push(user.id);
-                            anchor_ranges.push(start..end);
-                        }
+                        mentioned_user_ids.push(user.id);
+                        anchor_ranges.push(start..end);
                     }
                 }
 

crates/collab_ui/src/collab_panel.rs πŸ”—

@@ -311,10 +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() {
-                                return;
-                            }
+                        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);
@@ -491,11 +491,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() {
-                        self.entries.push(ListEntry::ChannelNotes { channel_id });
-                        self.entries.push(ListEntry::ChannelChat { 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.
@@ -639,10 +639,10 @@ impl CollabPanel {
                 &Default::default(),
                 executor.clone(),
             ));
-            if let Some(state) = &self.channel_editing_state {
-                if matches!(state, ChannelEditingState::Create { location: None, .. }) {
-                    self.entries.push(ListEntry::ChannelEditor { depth: 0 });
-                }
+            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 {
@@ -1552,98 +1552,93 @@ impl CollabPanel {
             return;
         }
 
-        if let Some(selection) = self.selection {
-            if let Some(entry) = self.entries.get(selection) {
-                match entry {
-                    ListEntry::Header(section) => match section {
-                        Section::ActiveCall => Self::leave_call(window, cx),
-                        Section::Channels => self.new_root_channel(window, cx),
-                        Section::Contacts => self.toggle_contact_finder(window, cx),
-                        Section::ContactRequests
-                        | Section::Online
-                        | Section::Offline
-                        | Section::ChannelInvites => {
-                            self.toggle_section_expanded(*section, cx);
-                        }
-                    },
-                    ListEntry::Contact { contact, calling } => {
-                        if contact.online && !contact.busy && !calling {
-                            self.call(contact.user.id, window, cx);
-                        }
+        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),
+                    Section::Channels => self.new_root_channel(window, cx),
+                    Section::Contacts => self.toggle_contact_finder(window, cx),
+                    Section::ContactRequests
+                    | Section::Online
+                    | Section::Offline
+                    | Section::ChannelInvites => {
+                        self.toggle_section_expanded(*section, cx);
                     }
-                    ListEntry::ParticipantProject {
-                        project_id,
-                        host_user_id,
-                        ..
-                    } => {
-                        if let Some(workspace) = self.workspace.upgrade() {
-                            let app_state = workspace.read(cx).app_state().clone();
-                            workspace::join_in_room_project(
-                                *project_id,
-                                *host_user_id,
-                                app_state,
-                                cx,
-                            )
+                },
+                ListEntry::Contact { contact, calling } => {
+                    if contact.online && !contact.busy && !calling {
+                        self.call(contact.user.id, window, cx);
+                    }
+                }
+                ListEntry::ParticipantProject {
+                    project_id,
+                    host_user_id,
+                    ..
+                } => {
+                    if let Some(workspace) = self.workspace.upgrade() {
+                        let app_state = workspace.read(cx).app_state().clone();
+                        workspace::join_in_room_project(*project_id, *host_user_id, app_state, cx)
                             .detach_and_prompt_err(
                                 "Failed to join project",
                                 window,
                                 cx,
                                 |_, _, _| None,
                             );
-                        }
-                    }
-                    ListEntry::ParticipantScreen { peer_id, .. } => {
-                        let Some(peer_id) = peer_id else {
-                            return;
-                        };
-                        if let Some(workspace) = self.workspace.upgrade() {
-                            workspace.update(cx, |workspace, cx| {
-                                workspace.open_shared_screen(*peer_id, window, cx)
-                            });
-                        }
-                    }
-                    ListEntry::Channel { channel, .. } => {
-                        let is_active = maybe!({
-                            let call_channel = ActiveCall::global(cx)
-                                .read(cx)
-                                .room()?
-                                .read(cx)
-                                .channel_id()?;
-
-                            Some(call_channel == channel.id)
-                        })
-                        .unwrap_or(false);
-                        if is_active {
-                            self.open_channel_notes(channel.id, window, cx)
-                        } else {
-                            self.join_channel(channel.id, window, cx)
-                        }
                     }
-                    ListEntry::ContactPlaceholder => self.toggle_contact_finder(window, cx),
-                    ListEntry::CallParticipant { user, peer_id, .. } => {
-                        if Some(user) == self.user_store.read(cx).current_user().as_ref() {
-                            Self::leave_call(window, cx);
-                        } else if let Some(peer_id) = peer_id {
-                            self.workspace
-                                .update(cx, |workspace, cx| workspace.follow(*peer_id, window, cx))
-                                .ok();
-                        }
-                    }
-                    ListEntry::IncomingRequest(user) => {
-                        self.respond_to_contact_request(user.id, true, window, cx)
-                    }
-                    ListEntry::ChannelInvite(channel) => {
-                        self.respond_to_channel_invite(channel.id, true, cx)
+                }
+                ListEntry::ParticipantScreen { peer_id, .. } => {
+                    let Some(peer_id) = peer_id else {
+                        return;
+                    };
+                    if let Some(workspace) = self.workspace.upgrade() {
+                        workspace.update(cx, |workspace, cx| {
+                            workspace.open_shared_screen(*peer_id, window, cx)
+                        });
                     }
-                    ListEntry::ChannelNotes { channel_id } => {
-                        self.open_channel_notes(*channel_id, window, cx)
+                }
+                ListEntry::Channel { channel, .. } => {
+                    let is_active = maybe!({
+                        let call_channel = ActiveCall::global(cx)
+                            .read(cx)
+                            .room()?
+                            .read(cx)
+                            .channel_id()?;
+
+                        Some(call_channel == channel.id)
+                    })
+                    .unwrap_or(false);
+                    if is_active {
+                        self.open_channel_notes(channel.id, window, cx)
+                    } else {
+                        self.join_channel(channel.id, window, cx)
                     }
-                    ListEntry::ChannelChat { channel_id } => {
-                        self.join_channel_chat(*channel_id, window, cx)
+                }
+                ListEntry::ContactPlaceholder => self.toggle_contact_finder(window, cx),
+                ListEntry::CallParticipant { user, peer_id, .. } => {
+                    if Some(user) == self.user_store.read(cx).current_user().as_ref() {
+                        Self::leave_call(window, cx);
+                    } else if let Some(peer_id) = peer_id {
+                        self.workspace
+                            .update(cx, |workspace, cx| workspace.follow(*peer_id, window, cx))
+                            .ok();
                     }
-                    ListEntry::OutgoingRequest(_) => {}
-                    ListEntry::ChannelEditor { .. } => {}
                 }
+                ListEntry::IncomingRequest(user) => {
+                    self.respond_to_contact_request(user.id, true, window, cx)
+                }
+                ListEntry::ChannelInvite(channel) => {
+                    self.respond_to_channel_invite(channel.id, true, cx)
+                }
+                ListEntry::ChannelNotes { channel_id } => {
+                    self.open_channel_notes(*channel_id, window, cx)
+                }
+                ListEntry::ChannelChat { channel_id } => {
+                    self.join_channel_chat(*channel_id, window, cx)
+                }
+                ListEntry::OutgoingRequest(_) => {}
+                ListEntry::ChannelEditor { .. } => {}
             }
         }
     }

crates/collab_ui/src/notification_panel.rs πŸ”—

@@ -121,13 +121,12 @@ 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();
-                        }
+                    {
+                        task.detach();
                     }
                 },
             ));
@@ -469,20 +468,19 @@ impl NotificationPanel {
             channel_id,
             ..
         } = notification.clone()
+            && let Some(workspace) = self.workspace.upgrade()
         {
-            if let Some(workspace) = self.workspace.upgrade() {
-                window.defer(cx, move |window, cx| {
-                    workspace.update(cx, |workspace, cx| {
-                        if let Some(panel) = workspace.focus_panel::<ChatPanel>(window, cx) {
-                            panel.update(cx, |panel, cx| {
-                                panel
-                                    .select_channel(ChannelId(channel_id), Some(message_id), cx)
-                                    .detach_and_log_err(cx);
-                            });
-                        }
-                    });
+            window.defer(cx, move |window, cx| {
+                workspace.update(cx, |workspace, cx| {
+                    if let Some(panel) = workspace.focus_panel::<ChatPanel>(window, cx) {
+                        panel.update(cx, |panel, cx| {
+                            panel
+                                .select_channel(ChannelId(channel_id), Some(message_id), cx)
+                                .detach_and_log_err(cx);
+                        });
+                    }
                 });
-            }
+            });
         }
     }
 
@@ -491,18 +489,18 @@ impl NotificationPanel {
             return false;
         }
 
-        if let Notification::ChannelMessageMention { channel_id, .. } = &notification {
-            if let Some(workspace) = self.workspace.upgrade() {
-                return if let Some(panel) = workspace.read(cx).panel::<ChatPanel>(cx) {
-                    let panel = panel.read(cx);
-                    panel.is_scrolled_to_bottom()
-                        && panel
-                            .active_chat()
-                            .map_or(false, |chat| chat.read(cx).channel_id.0 == *channel_id)
-                } else {
-                    false
-                };
-            }
+        if let Notification::ChannelMessageMention { channel_id, .. } = &notification
+            && let Some(workspace) = self.workspace.upgrade()
+        {
+            return if let Some(panel) = workspace.read(cx).panel::<ChatPanel>(cx) {
+                let panel = panel.read(cx);
+                panel.is_scrolled_to_bottom()
+                    && panel
+                        .active_chat()
+                        .map_or(false, |chat| chat.read(cx).channel_id.0 == *channel_id)
+            } else {
+                false
+            };
         }
 
         false
@@ -582,16 +580,16 @@ impl NotificationPanel {
     }
 
     fn remove_toast(&mut self, notification_id: u64, cx: &mut Context<Self>) {
-        if let Some((current_id, _)) = &self.current_notification_toast {
-            if *current_id == notification_id {
-                self.current_notification_toast.take();
-                self.workspace
-                    .update(cx, |workspace, cx| {
-                        let id = NotificationId::unique::<NotificationToast>();
-                        workspace.dismiss_notification(&id, cx)
-                    })
-                    .ok();
-            }
+        if let Some((current_id, _)) = &self.current_notification_toast
+            && *current_id == notification_id
+        {
+            self.current_notification_toast.take();
+            self.workspace
+                .update(cx, |workspace, cx| {
+                    let id = NotificationId::unique::<NotificationToast>();
+                    workspace.dismiss_notification(&id, cx)
+                })
+                .ok();
         }
     }
 

crates/context_server/src/client.rs πŸ”—

@@ -271,10 +271,10 @@ impl Client {
                     );
                 }
             } else if let Ok(response) = serde_json::from_str::<AnyResponse>(&message) {
-                if let Some(handlers) = response_handlers.lock().as_mut() {
-                    if let Some(handler) = handlers.remove(&response.id) {
-                        handler(Ok(message.to_string()));
-                    }
+                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::<AnyNotification>(&message) {
                 let mut notification_handlers = notification_handlers.lock();

crates/copilot/src/copilot.rs πŸ”—

@@ -608,15 +608,13 @@ impl Copilot {
                                                 sign_in_status: status,
                                                 ..
                                             }) = &mut this.server
-                                            {
-                                                if let SignInStatus::SigningIn {
+                                                && let SignInStatus::SigningIn {
                                                     prompt: prompt_flow,
                                                     ..
                                                 } = status
-                                                {
-                                                    *prompt_flow = Some(flow.clone());
-                                                    cx.notify();
-                                                }
+                                            {
+                                                *prompt_flow = Some(flow.clone());
+                                                cx.notify();
                                             }
                                         })?;
                                         let response = lsp
@@ -782,59 +780,58 @@ impl Copilot {
         event: &language::BufferEvent,
         cx: &mut Context<Self>,
     ) -> Result<()> {
-        if let Ok(server) = self.server.as_running() {
-            if let Some(registered_buffer) = server.registered_buffers.get_mut(&buffer.entity_id())
-            {
-                match event {
-                    language::BufferEvent::Edited => {
-                        drop(registered_buffer.report_changes(&buffer, cx));
-                    }
-                    language::BufferEvent::Saved => {
+        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 => {
+                    drop(registered_buffer.report_changes(&buffer, cx));
+                }
+                language::BufferEvent::Saved => {
+                    server
+                        .lsp
+                        .notify::<lsp::notification::DidSaveTextDocument>(
+                            &lsp::DidSaveTextDocumentParams {
+                                text_document: lsp::TextDocumentIdentifier::new(
+                                    registered_buffer.uri.clone(),
+                                ),
+                                text: None,
+                            },
+                        )?;
+                }
+                language::BufferEvent::FileHandleChanged
+                | language::BufferEvent::LanguageChanged => {
+                    let new_language_id = id_for_language(buffer.read(cx).language());
+                    let Ok(new_uri) = uri_for_buffer(&buffer, cx) else {
+                        return Ok(());
+                    };
+                    if new_uri != registered_buffer.uri
+                        || new_language_id != registered_buffer.language_id
+                    {
+                        let old_uri = mem::replace(&mut registered_buffer.uri, new_uri);
+                        registered_buffer.language_id = new_language_id;
+                        server
+                            .lsp
+                            .notify::<lsp::notification::DidCloseTextDocument>(
+                                &lsp::DidCloseTextDocumentParams {
+                                    text_document: lsp::TextDocumentIdentifier::new(old_uri),
+                                },
+                            )?;
                         server
                             .lsp
-                            .notify::<lsp::notification::DidSaveTextDocument>(
-                                &lsp::DidSaveTextDocumentParams {
-                                    text_document: lsp::TextDocumentIdentifier::new(
+                            .notify::<lsp::notification::DidOpenTextDocument>(
+                                &lsp::DidOpenTextDocumentParams {
+                                    text_document: lsp::TextDocumentItem::new(
                                         registered_buffer.uri.clone(),
+                                        registered_buffer.language_id.clone(),
+                                        registered_buffer.snapshot_version,
+                                        registered_buffer.snapshot.text(),
                                     ),
-                                    text: None,
                                 },
                             )?;
                     }
-                    language::BufferEvent::FileHandleChanged
-                    | language::BufferEvent::LanguageChanged => {
-                        let new_language_id = id_for_language(buffer.read(cx).language());
-                        let Ok(new_uri) = uri_for_buffer(&buffer, cx) else {
-                            return Ok(());
-                        };
-                        if new_uri != registered_buffer.uri
-                            || new_language_id != registered_buffer.language_id
-                        {
-                            let old_uri = mem::replace(&mut registered_buffer.uri, new_uri);
-                            registered_buffer.language_id = new_language_id;
-                            server
-                                .lsp
-                                .notify::<lsp::notification::DidCloseTextDocument>(
-                                    &lsp::DidCloseTextDocumentParams {
-                                        text_document: lsp::TextDocumentIdentifier::new(old_uri),
-                                    },
-                                )?;
-                            server
-                                .lsp
-                                .notify::<lsp::notification::DidOpenTextDocument>(
-                                    &lsp::DidOpenTextDocumentParams {
-                                        text_document: lsp::TextDocumentItem::new(
-                                            registered_buffer.uri.clone(),
-                                            registered_buffer.language_id.clone(),
-                                            registered_buffer.snapshot_version,
-                                            registered_buffer.snapshot.text(),
-                                        ),
-                                    },
-                                )?;
-                        }
-                    }
-                    _ => {}
                 }
+                _ => {}
             }
         }
 
@@ -842,17 +839,17 @@ impl Copilot {
     }
 
     fn unregister_buffer(&mut self, buffer: &WeakEntity<Buffer>) {
-        if let Ok(server) = self.server.as_running() {
-            if let Some(buffer) = server.registered_buffers.remove(&buffer.entity_id()) {
-                server
-                    .lsp
-                    .notify::<lsp::notification::DidCloseTextDocument>(
-                        &lsp::DidCloseTextDocumentParams {
-                            text_document: lsp::TextDocumentIdentifier::new(buffer.uri),
-                        },
-                    )
-                    .ok();
-            }
+        if let Ok(server) = self.server.as_running()
+            && let Some(buffer) = server.registered_buffers.remove(&buffer.entity_id())
+        {
+            server
+                .lsp
+                .notify::<lsp::notification::DidCloseTextDocument>(
+                    &lsp::DidCloseTextDocumentParams {
+                        text_document: lsp::TextDocumentIdentifier::new(buffer.uri),
+                    },
+                )
+                .ok();
         }
     }
 

crates/dap_adapters/src/javascript.rs πŸ”—

@@ -99,10 +99,10 @@ impl JsDebugAdapter {
                 }
             }
 
-            if let Some(env) = configuration.get("env").cloned() {
-                if let Ok(env) = serde_json::from_value(env) {
-                    envs = env;
-                }
+            if let Some(env) = configuration.get("env").cloned()
+                && let Ok(env) = serde_json::from_value(env)
+            {
+                envs = env;
             }
 
             configuration

crates/debugger_tools/src/dap_log.rs πŸ”—

@@ -661,11 +661,11 @@ impl ToolbarItemView for DapLogToolbarItemView {
         _window: &mut Window,
         cx: &mut Context<Self>,
     ) -> workspace::ToolbarItemLocation {
-        if let Some(item) = active_pane_item {
-            if let Some(log_view) = item.downcast::<DapLogView>() {
-                self.log_view = Some(log_view.clone());
-                return workspace::ToolbarItemLocation::PrimaryLeft;
-            }
+        if let Some(item) = active_pane_item
+            && let Some(log_view) = item.downcast::<DapLogView>()
+        {
+            self.log_view = Some(log_view.clone());
+            return workspace::ToolbarItemLocation::PrimaryLeft;
         }
         self.log_view = None;
 

crates/debugger_ui/src/debugger_panel.rs πŸ”—

@@ -530,10 +530,9 @@ impl DebugPanel {
                     .active_session
                     .as_ref()
                     .map(|session| session.entity_id())
+                    && active_session_id == entity_id
                 {
-                    if active_session_id == entity_id {
-                        this.active_session = this.sessions_with_children.keys().next().cloned();
-                    }
+                    this.active_session = this.sessions_with_children.keys().next().cloned();
                 }
                 cx.notify()
             })
@@ -1302,10 +1301,10 @@ impl DebugPanel {
         cx: &mut Context<'_, Self>,
     ) -> Option<SharedString> {
         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) {
-                return Some(label.into());
-            }
+        if let Some(adapter) = DapRegistry::global(cx).adapter(&adapter)
+            && let Some(label) = adapter.label_for_child_session(request)
+        {
+            return Some(label.into());
         }
         None
     }

crates/debugger_ui/src/new_process_modal.rs πŸ”—

@@ -343,10 +343,10 @@ impl NewProcessModal {
             return;
         }
 
-        if let NewProcessMode::Launch = &self.mode {
-            if self.configure_mode.read(cx).save_to_debug_json.selected() {
-                self.save_debug_scenario(window, cx);
-            }
+        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 {

crates/debugger_ui/src/session/running/breakpoint_list.rs πŸ”—

@@ -239,11 +239,9 @@ impl BreakpointList {
     }
 
     fn select_next(&mut self, _: &menu::SelectNext, window: &mut Window, cx: &mut Context<Self>) {
-        if self.strip_mode.is_some() {
-            if self.input.focus_handle(cx).contains_focused(window, cx) {
-                cx.propagate();
-                return;
-            }
+        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,
@@ -265,11 +263,9 @@ impl BreakpointList {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if self.strip_mode.is_some() {
-            if self.input.focus_handle(cx).contains_focused(window, cx) {
-                cx.propagate();
-                return;
-            }
+        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,
@@ -286,11 +282,9 @@ impl BreakpointList {
     }
 
     fn select_first(&mut self, _: &menu::SelectFirst, window: &mut Window, cx: &mut Context<Self>) {
-        if self.strip_mode.is_some() {
-            if self.input.focus_handle(cx).contains_focused(window, cx) {
-                cx.propagate();
-                return;
-            }
+        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)
@@ -301,11 +295,9 @@ impl BreakpointList {
     }
 
     fn select_last(&mut self, _: &menu::SelectLast, window: &mut Window, cx: &mut Context<Self>) {
-        if self.strip_mode.is_some() {
-            if self.input.focus_handle(cx).contains_focused(window, cx) {
-                cx.propagate();
-                return;
-            }
+        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)
@@ -401,11 +393,9 @@ 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) {
-                cx.propagate();
-                return;
-            }
+        if self.strip_mode.is_some() && self.input.focus_handle(cx).contains_focused(window, cx) {
+            cx.propagate();
+            return;
         }
 
         match &mut entry.kind {

crates/debugger_ui/src/session/running/console.rs πŸ”—

@@ -611,17 +611,16 @@ 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()
-                    {
-                        string_matches.push(StringMatchCandidate {
-                            id: 0,
-                            string: evaluate_name.clone(),
-                            char_bag: evaluate_name.chars().collect(),
-                        });
-                    }
+                {
+                    string_matches.push(StringMatchCandidate {
+                        id: 0,
+                        string: evaluate_name.clone(),
+                        char_bag: evaluate_name.chars().collect(),
+                    });
                 }
 
                 if variables

crates/diagnostics/src/diagnostics.rs πŸ”—

@@ -639,17 +639,15 @@ impl ProjectDiagnosticsEditor {
                 #[cfg(test)]
                 let cloned_blocks = blocks.clone();
 
-                if was_empty {
-                    if 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| {
-                                s.select_anchor_ranges([range_to_select]);
-                            })
-                        });
-                        if this.focus_handle.is_focused(window) {
-                            this.editor.read(cx).focus_handle(cx).focus(window);
-                        }
+                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| {
+                            s.select_anchor_ranges([range_to_select]);
+                        })
+                    });
+                    if this.focus_handle.is_focused(window) {
+                        this.editor.read(cx).focus_handle(cx).focus(window);
                     }
                 }
 
@@ -980,18 +978,16 @@ 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())
-            {
-                let row_count = end_row.saturating_sub(start_row);
-                if row_count <= max_row_count {
-                    return Some(RangeInclusive::new(
-                        outline_range.start.row,
-                        outline_range.end.row,
-                    ));
-                }
+        {
+            let row_count = end_row.saturating_sub(start_row);
+            if row_count <= max_row_count {
+                return Some(RangeInclusive::new(
+                    outline_range.start.row,
+                    outline_range.end.row,
+                ));
             }
         }
     }

crates/editor/src/display_map.rs πŸ”—

@@ -969,13 +969,13 @@ 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 {
-                        // 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 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);
                     }
                 }
 
@@ -2351,11 +2351,12 @@ 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 {
-                    last_chunk.push_str(chunk.text);
-                    continue;
-                }
+            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,11 +2902,12 @@ 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 {
-                    last_chunk.push_str(chunk.text);
-                    continue;
-                }
+            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));
         }

crates/editor/src/display_map/block_map.rs πŸ”—

@@ -525,26 +525,25 @@ 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
-                    && cursor.end() == old_start
-                    && transform
-                        .block
-                        .as_ref()
-                        .map_or(true, |b| !b.is_replacement())
-                {
-                    // Preserve the transform (push and next)
-                    new_transforms.push(transform.clone(), &());
-                    cursor.next();
+            if let Some(transform) = cursor.item()
+                && transform.summary.input_rows > 0
+                && cursor.end() == old_start
+                && transform
+                    .block
+                    .as_ref()
+                    .map_or(true, |b| !b.is_replacement())
+            {
+                // Preserve the transform (push and next)
+                new_transforms.push(transform.clone(), &());
+                cursor.next();
 
-                    // Preserve below blocks at end of edit
-                    while let Some(transform) = cursor.item() {
-                        if transform.block.as_ref().map_or(false, |b| b.place_below()) {
-                            new_transforms.push(transform.clone(), &());
-                            cursor.next();
-                        } else {
-                            break;
-                        }
+                // Preserve below blocks at end of edit
+                while let Some(transform) = cursor.item() {
+                    if transform.block.as_ref().map_or(false, |b| b.place_below()) {
+                        new_transforms.push(transform.clone(), &());
+                        cursor.next();
+                    } else {
+                        break;
                     }
                 }
             }
@@ -657,10 +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 {
-                                return None;
-                            }
+                        if let BlockPlacement::Above(row) = placement
+                            && row < new_start
+                        {
+                            return None;
                         }
                         Some((placement, Block::Custom(block.clone())))
                     }),
@@ -977,10 +976,10 @@ impl BlockMapReader<'_> {
                 break;
             }
 
-            if let Some(BlockId::Custom(id)) = transform.block.as_ref().map(|block| block.id()) {
-                if id == block_id {
-                    return Some(cursor.start().1);
-                }
+            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,14 +1298,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() {
-                input_start += rows.start - transform_output_start;
-                input_end += cmp::min(
-                    rows.end - transform_output_start,
-                    transform.summary.input_rows,
-                );
-            }
+        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 {
@@ -1472,18 +1471,18 @@ impl BlockSnapshot {
                 longest_row_chars = summary.longest_row_chars;
             }
 
-            if let Some(transform) = cursor.item() {
-                if 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;
-                    let wrap_end_row = input_start.0 + overshoot;
-                    let summary = self
-                        .wrap_snapshot
-                        .text_summary_for_range(wrap_start_row..wrap_end_row);
-                    if summary.longest_row_chars > longest_row_chars {
-                        longest_row = BlockRow(output_start.0 + summary.longest_row);
-                    }
+            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;
+                let wrap_end_row = input_start.0 + overshoot;
+                let summary = self
+                    .wrap_snapshot
+                    .text_summary_for_range(wrap_start_row..wrap_end_row);
+                if summary.longest_row_chars > longest_row_chars {
+                    longest_row = BlockRow(output_start.0 + summary.longest_row);
                 }
             }
         }
@@ -1557,12 +1556,11 @@ 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)
-                            {
-                                return BlockPoint(output_start);
-                            }
+                        if block.is_replacement()
+                            && (((bias == Bias::Left || search_left) && output_start <= point.0)
+                                || (!search_left && output_start >= point.0))
+                        {
+                            return BlockPoint(output_start);
                         }
                     }
                     None => {
@@ -3228,34 +3226,32 @@ mod tests {
                 let mut is_in_replace_block = false;
                 if let Some((BlockPlacement::Replace(replace_range), block)) =
                     sorted_blocks_iter.peek()
+                    && wrap_row >= replace_range.start().0
                 {
-                    if wrap_row >= replace_range.start().0 {
-                        is_in_replace_block = true;
+                    is_in_replace_block = true;
 
-                        if wrap_row == replace_range.start().0 {
-                            if matches!(block, Block::FoldedBuffer { .. }) {
-                                expected_buffer_rows.push(None);
-                            } else {
-                                expected_buffer_rows
-                                    .push(input_buffer_rows[multibuffer_row as usize]);
-                            }
+                    if wrap_row == replace_range.start().0 {
+                        if matches!(block, Block::FoldedBuffer { .. }) {
+                            expected_buffer_rows.push(None);
+                        } else {
+                            expected_buffer_rows.push(input_buffer_rows[multibuffer_row as usize]);
                         }
+                    }
 
-                        if wrap_row == replace_range.end().0 {
-                            expected_block_positions.push((block_row, block.id()));
-                            let text = "\n".repeat((block.height() - 1) as usize);
-                            if block_row > 0 {
-                                expected_text.push('\n');
-                            }
-                            expected_text.push_str(&text);
-
-                            for _ in 1..block.height() {
-                                expected_buffer_rows.push(None);
-                            }
-                            block_row += block.height();
+                    if wrap_row == replace_range.end().0 {
+                        expected_block_positions.push((block_row, block.id()));
+                        let text = "\n".repeat((block.height() - 1) as usize);
+                        if block_row > 0 {
+                            expected_text.push('\n');
+                        }
+                        expected_text.push_str(&text);
 
-                            sorted_blocks_iter.next();
+                        for _ in 1..block.height() {
+                            expected_buffer_rows.push(None);
                         }
+                        block_row += block.height();
+
+                        sorted_blocks_iter.next();
                     }
                 }
 

crates/editor/src/display_map/fold_map.rs πŸ”—

@@ -289,25 +289,25 @@ 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 {
-                    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)
-                        ..inlay_snapshot.to_inlay_offset(buffer_end);
-                    edits.push(InlayEdit {
-                        old: inlay_range.clone(),
-                        new: inlay_range.clone(),
-                    });
+            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)
+                    ..inlay_snapshot.to_inlay_offset(buffer_end);
+                edits.push(InlayEdit {
+                    old: inlay_range.clone(),
+                    new: inlay_range.clone(),
+                });
 
-                    self.0.snapshot.fold_metadata_by_id.insert(
-                        id,
-                        FoldMetadata {
-                            range: metadata.range,
-                            width: Some(new_width),
-                        },
-                    );
-                }
+                self.0.snapshot.fold_metadata_by_id.insert(
+                    id,
+                    FoldMetadata {
+                        range: metadata.range,
+                        width: Some(new_width),
+                    },
+                );
             }
         }
 
@@ -417,18 +417,18 @@ 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() {
-                        new_transforms.update_last(
-                            |transform| {
-                                if !transform.is_fold() {
-                                    transform.summary.add_summary(&item.summary, &());
-                                    cursor.next();
-                                }
-                            },
-                            &(),
-                        );
-                    }
+                if let Some(item) = cursor.item()
+                    && !item.is_fold()
+                {
+                    new_transforms.update_last(
+                        |transform| {
+                            if !transform.is_fold() {
+                                transform.summary.add_summary(&item.summary, &());
+                                cursor.next();
+                            }
+                        },
+                        &(),
+                    );
                 }
                 new_transforms.append(cursor.slice(&edit.old.start, Bias::Left), &());
                 edit.new.start -= edit.old.start - *cursor.start();

crates/editor/src/display_map/inlay_map.rs πŸ”—

@@ -557,11 +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 {
-                        push_isomorphic(&mut new_transforms, *transform);
-                        cursor.next();
-                    }
+                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.

crates/editor/src/display_map/wrap_map.rs πŸ”—

@@ -249,48 +249,48 @@ impl WrapMap {
             return;
         }
 
-        if let Some(wrap_width) = self.wrap_width {
-            if 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();
-                let (font, font_size) = self.font_with_size.clone();
-                let update_task = cx.background_spawn(async move {
-                    let mut edits = Patch::default();
-                    let mut line_wrapper = text_system.line_wrapper(font, font_size);
-                    for (tab_snapshot, tab_edits) in pending_edits {
-                        let wrap_edits = snapshot
-                            .update(tab_snapshot, &tab_edits, wrap_width, &mut line_wrapper)
-                            .await;
-                        edits = edits.compose(&wrap_edits);
-                    }
-                    (snapshot, edits)
-                });
+        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();
+            let (font, font_size) = self.font_with_size.clone();
+            let update_task = cx.background_spawn(async move {
+                let mut edits = Patch::default();
+                let mut line_wrapper = text_system.line_wrapper(font, font_size);
+                for (tab_snapshot, tab_edits) in pending_edits {
+                    let wrap_edits = snapshot
+                        .update(tab_snapshot, &tab_edits, wrap_width, &mut line_wrapper)
+                        .await;
+                    edits = edits.compose(&wrap_edits);
+                }
+                (snapshot, edits)
+            });
 
-                match cx
-                    .background_executor()
-                    .block_with_timeout(Duration::from_millis(1), update_task)
-                {
-                    Ok((snapshot, output_edits)) => {
-                        self.snapshot = snapshot;
-                        self.edits_since_sync = self.edits_since_sync.compose(&output_edits);
-                    }
-                    Err(update_task) => {
-                        self.background_task = Some(cx.spawn(async move |this, cx| {
-                            let (snapshot, edits) = update_task.await;
-                            this.update(cx, |this, cx| {
-                                this.snapshot = snapshot;
-                                this.edits_since_sync = this
-                                    .edits_since_sync
-                                    .compose(mem::take(&mut this.interpolated_edits).invert())
-                                    .compose(&edits);
-                                this.background_task = None;
-                                this.flush_edits(cx);
-                                cx.notify();
-                            })
-                            .ok();
-                        }));
-                    }
+            match cx
+                .background_executor()
+                .block_with_timeout(Duration::from_millis(1), update_task)
+            {
+                Ok((snapshot, output_edits)) => {
+                    self.snapshot = snapshot;
+                    self.edits_since_sync = self.edits_since_sync.compose(&output_edits);
+                }
+                Err(update_task) => {
+                    self.background_task = Some(cx.spawn(async move |this, cx| {
+                        let (snapshot, edits) = update_task.await;
+                        this.update(cx, |this, cx| {
+                            this.snapshot = snapshot;
+                            this.edits_since_sync = this
+                                .edits_since_sync
+                                .compose(mem::take(&mut this.interpolated_edits).invert())
+                                .compose(&edits);
+                            this.background_task = None;
+                            this.flush_edits(cx);
+                            cx.notify();
+                        })
+                        .ok();
+                    }));
                 }
             }
         }
@@ -1065,12 +1065,12 @@ impl sum_tree::Item for Transform {
 }
 
 fn push_isomorphic(transforms: &mut Vec<Transform>, summary: TextSummary) {
-    if let Some(last_transform) = transforms.last_mut() {
-        if last_transform.is_isomorphic() {
-            last_transform.summary.input += &summary;
-            last_transform.summary.output += &summary;
-            return;
-        }
+    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));
 }

crates/editor/src/editor.rs πŸ”—

@@ -942,10 +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() {
-                mem::swap(&mut last.original, current);
-            }
+        if let Some(last) = self.changes.last_mut()
+            && let Some(current) = last.current.as_mut()
+        {
+            mem::swap(&mut last.original, current);
         }
     }
 }
@@ -1861,114 +1861,110 @@ impl Editor {
             .then(|| language_settings::SoftWrap::None);
 
         let mut project_subscriptions = Vec::new();
-        if full_mode {
-            if let Some(project) = project.as_ref() {
-                project_subscriptions.push(cx.subscribe_in(
-                    project,
-                    window,
-                    |editor, _, event, window, cx| match event {
-                        project::Event::RefreshCodeLens => {
-                            // we always query lens with actions, without storing them, always refreshing them
-                        }
-                        project::Event::RefreshInlayHints => {
-                            editor
-                                .refresh_inlay_hints(InlayHintRefreshReason::RefreshRequested, cx);
-                        }
-                        project::Event::LanguageServerAdded(..)
-                        | project::Event::LanguageServerRemoved(..) => {
-                            if editor.tasks_update_task.is_none() {
-                                editor.tasks_update_task =
-                                    Some(editor.refresh_runnables(window, cx));
-                            }
+        if full_mode && let Some(project) = project.as_ref() {
+            project_subscriptions.push(cx.subscribe_in(
+                project,
+                window,
+                |editor, _, event, window, cx| match event {
+                    project::Event::RefreshCodeLens => {
+                        // we always query lens with actions, without storing them, always refreshing them
+                    }
+                    project::Event::RefreshInlayHints => {
+                        editor.refresh_inlay_hints(InlayHintRefreshReason::RefreshRequested, cx);
+                    }
+                    project::Event::LanguageServerAdded(..)
+                    | project::Event::LanguageServerRemoved(..) => {
+                        if editor.tasks_update_task.is_none() {
+                            editor.tasks_update_task = Some(editor.refresh_runnables(window, cx));
                         }
-                        project::Event::SnippetEdit(id, snippet_edits) => {
-                            if let Some(buffer) = editor.buffer.read(cx).buffer(*id) {
-                                let focus_handle = editor.focus_handle(cx);
-                                if focus_handle.is_focused(window) {
-                                    let snapshot = buffer.read(cx).snapshot();
-                                    for (range, snippet) in snippet_edits {
-                                        let editor_range =
-                                            language::range_from_lsp(*range).to_offset(&snapshot);
-                                        editor
-                                            .insert_snippet(
-                                                &[editor_range],
-                                                snippet.clone(),
-                                                window,
-                                                cx,
-                                            )
-                                            .ok();
-                                    }
+                    }
+                    project::Event::SnippetEdit(id, snippet_edits) => {
+                        if let Some(buffer) = editor.buffer.read(cx).buffer(*id) {
+                            let focus_handle = editor.focus_handle(cx);
+                            if focus_handle.is_focused(window) {
+                                let snapshot = buffer.read(cx).snapshot();
+                                for (range, snippet) in snippet_edits {
+                                    let editor_range =
+                                        language::range_from_lsp(*range).to_offset(&snapshot);
+                                    editor
+                                        .insert_snippet(
+                                            &[editor_range],
+                                            snippet.clone(),
+                                            window,
+                                            cx,
+                                        )
+                                        .ok();
                                 }
                             }
                         }
-                        project::Event::LanguageServerBufferRegistered { buffer_id, .. } => {
-                            if editor.buffer().read(cx).buffer(*buffer_id).is_some() {
-                                editor.update_lsp_data(false, Some(*buffer_id), window, cx);
-                            }
+                    }
+                    project::Event::LanguageServerBufferRegistered { buffer_id, .. } => {
+                        if editor.buffer().read(cx).buffer(*buffer_id).is_some() {
+                            editor.update_lsp_data(false, Some(*buffer_id), window, cx);
                         }
-                        _ => {}
+                    }
+                    _ => {}
+                },
+            ));
+            if let Some(task_inventory) = project
+                .read(cx)
+                .task_store()
+                .read(cx)
+                .task_inventory()
+                .cloned()
+            {
+                project_subscriptions.push(cx.observe_in(
+                    &task_inventory,
+                    window,
+                    |editor, _, window, cx| {
+                        editor.tasks_update_task = Some(editor.refresh_runnables(window, cx));
                     },
                 ));
-                if let Some(task_inventory) = project
-                    .read(cx)
-                    .task_store()
-                    .read(cx)
-                    .task_inventory()
-                    .cloned()
-                {
-                    project_subscriptions.push(cx.observe_in(
-                        &task_inventory,
-                        window,
-                        |editor, _, window, cx| {
-                            editor.tasks_update_task = Some(editor.refresh_runnables(window, cx));
-                        },
-                    ));
-                };
+            };
 
-                project_subscriptions.push(cx.subscribe_in(
-                    &project.read(cx).breakpoint_store(),
-                    window,
-                    |editor, _, event, window, cx| match event {
-                        BreakpointStoreEvent::ClearDebugLines => {
-                            editor.clear_row_highlights::<ActiveDebugLine>();
-                            editor.refresh_inline_values(cx);
+            project_subscriptions.push(cx.subscribe_in(
+                &project.read(cx).breakpoint_store(),
+                window,
+                |editor, _, event, window, cx| match event {
+                    BreakpointStoreEvent::ClearDebugLines => {
+                        editor.clear_row_highlights::<ActiveDebugLine>();
+                        editor.refresh_inline_values(cx);
+                    }
+                    BreakpointStoreEvent::SetDebugLine => {
+                        if editor.go_to_active_debug_line(window, cx) {
+                            cx.stop_propagation();
                         }
-                        BreakpointStoreEvent::SetDebugLine => {
-                            if editor.go_to_active_debug_line(window, cx) {
-                                cx.stop_propagation();
-                            }
 
-                            editor.refresh_inline_values(cx);
-                        }
-                        _ => {}
-                    },
-                ));
-                let git_store = project.read(cx).git_store().clone();
-                let project = project.clone();
-                project_subscriptions.push(cx.subscribe(&git_store, move |this, _, event, cx| {
-                    match event {
-                        GitStoreEvent::RepositoryUpdated(
-                            _,
-                            RepositoryEvent::Updated {
-                                new_instance: true, ..
-                            },
-                            _,
-                        ) => {
-                            this.load_diff_task = Some(
-                                update_uncommitted_diff_for_buffer(
-                                    cx.entity(),
-                                    &project,
-                                    this.buffer.read(cx).all_buffers(),
-                                    this.buffer.clone(),
-                                    cx,
-                                )
-                                .shared(),
-                            );
-                        }
-                        _ => {}
+                        editor.refresh_inline_values(cx);
                     }
-                }));
-            }
+                    _ => {}
+                },
+            ));
+            let git_store = project.read(cx).git_store().clone();
+            let project = project.clone();
+            project_subscriptions.push(cx.subscribe(&git_store, move |this, _, event, cx| {
+                match event {
+                    GitStoreEvent::RepositoryUpdated(
+                        _,
+                        RepositoryEvent::Updated {
+                            new_instance: true, ..
+                        },
+                        _,
+                    ) => {
+                        this.load_diff_task = Some(
+                            update_uncommitted_diff_for_buffer(
+                                cx.entity(),
+                                &project,
+                                this.buffer.read(cx).all_buffers(),
+                                this.buffer.clone(),
+                                cx,
+                            )
+                            .shared(),
+                        );
+                    }
+                    _ => {}
+                }
+            }));
         }
 
         let buffer_snapshot = buffer.read(cx).snapshot(cx);
@@ -2323,15 +2319,15 @@ 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() {
-                    let handle = project.update(cx, |project, cx| {
-                        project.register_buffer_with_language_servers(&buffer, cx)
-                    });
-                    editor
-                        .registered_buffers
-                        .insert(buffer.read(cx).remote_id(), handle);
-                }
+            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)
+                });
+                editor
+                    .registered_buffers
+                    .insert(buffer.read(cx).remote_id(), handle);
             }
 
             editor.minimap =
@@ -3035,20 +3031,19 @@ 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() {
-                        project.update(cx, |project, cx| {
-                            let Some(buffer) = self.buffer.read(cx).buffer(buffer_id) else {
-                                return;
-                            };
-                            self.registered_buffers.insert(
-                                buffer_id,
-                                project.register_buffer_with_language_servers(&buffer, cx),
-                            );
-                        })
-                    }
-                }
+            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;
+                    };
+                    self.registered_buffers.insert(
+                        buffer_id,
+                        project.register_buffer_with_language_servers(&buffer, cx),
+                    );
+                })
             }
 
             let mut context_menu = self.context_menu.borrow_mut();
@@ -3063,28 +3058,28 @@ 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 {
-                    let start_offset = selection_start.to_offset(buffer);
-                    let position_matches = start_offset == completion_position.to_offset(buffer);
-                    let continue_showing = if position_matches {
-                        if self.snippet_stack.is_empty() {
-                            buffer.char_kind_before(start_offset, true) == Some(CharKind::Word)
-                        } else {
-                            // Snippet choices can be shown even when the cursor is in whitespace.
-                            // Dismissing the menu with actions like backspace is handled by
-                            // invalidation regions.
-                            true
-                        }
-                    } else {
-                        false
-                    };
-
-                    if continue_showing {
-                        self.show_completions(&ShowCompletions { trigger: None }, window, cx);
+            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 {
+                    if self.snippet_stack.is_empty() {
+                        buffer.char_kind_before(start_offset, true) == Some(CharKind::Word)
                     } else {
-                        self.hide_context_menu(window, cx);
+                        // Snippet choices can be shown even when the cursor is in whitespace.
+                        // Dismissing the menu with actions like backspace is handled by
+                        // invalidation regions.
+                        true
                     }
+                } else {
+                    false
+                };
+
+                if continue_showing {
+                    self.show_completions(&ShowCompletions { trigger: None }, window, cx);
+                } else {
+                    self.hide_context_menu(window, cx);
                 }
             }
 
@@ -3115,30 +3110,27 @@ impl Editor {
         if selections.len() == 1 {
             cx.emit(SearchEvent::ActiveMatchChanged)
         }
-        if local {
-            if let Some((_, _, buffer_snapshot)) = buffer.as_singleton() {
-                let inmemory_selections = selections
-                    .iter()
-                    .map(|s| {
-                        text::ToPoint::to_point(&s.range().start.text_anchor, buffer_snapshot)
-                            ..text::ToPoint::to_point(&s.range().end.text_anchor, buffer_snapshot)
-                    })
-                    .collect();
-                self.update_restoration_data(cx, |data| {
-                    data.selections = inmemory_selections;
-                });
+        if local && let Some((_, _, buffer_snapshot)) = buffer.as_singleton() {
+            let inmemory_selections = selections
+                .iter()
+                .map(|s| {
+                    text::ToPoint::to_point(&s.range().start.text_anchor, buffer_snapshot)
+                        ..text::ToPoint::to_point(&s.range().end.text_anchor, buffer_snapshot)
+                })
+                .collect();
+            self.update_restoration_data(cx, |data| {
+                data.selections = inmemory_selections;
+            });
 
-                if WorkspaceSettings::get(None, cx).restore_on_startup
-                    != RestoreOnStartupBehavior::None
-                {
-                    if let Some(workspace_id) =
-                        self.workspace.as_ref().and_then(|workspace| workspace.1)
-                    {
-                        let snapshot = self.buffer().read(cx).snapshot(cx);
-                        let selections = selections.clone();
-                        let background_executor = cx.background_executor().clone();
-                        let editor_id = cx.entity().entity_id().as_u64() as ItemId;
-                        self.serialize_selections = cx.background_spawn(async move {
+            if WorkspaceSettings::get(None, cx).restore_on_startup != RestoreOnStartupBehavior::None
+                && let Some(workspace_id) =
+                    self.workspace.as_ref().and_then(|workspace| workspace.1)
+            {
+                let snapshot = self.buffer().read(cx).snapshot(cx);
+                let selections = selections.clone();
+                let background_executor = cx.background_executor().clone();
+                let editor_id = cx.entity().entity_id().as_u64() as ItemId;
+                self.serialize_selections = cx.background_spawn(async move {
                             background_executor.timer(SERIALIZATION_THROTTLE_TIME).await;
                             let db_selections = selections
                                 .iter()
@@ -3155,8 +3147,6 @@ impl Editor {
                                 .with_context(|| format!("persisting editor selections for editor {editor_id}, workspace {workspace_id:?}"))
                                 .log_err();
                         });
-                    }
-                }
             }
         }
 
@@ -4154,42 +4144,38 @@ 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) {
-                            let emoji_shortcode_start = Point::new(
-                                selection.start.row,
-                                selection.start.column - possible_emoji_short_code.len() as u32 - 1,
-                            );
+                && !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,
+                );
 
-                            // Remove shortcode from buffer
-                            edits.push((
-                                emoji_shortcode_start..selection.start,
-                                "".to_string().into(),
-                            ));
-                            new_selections.push((
-                                Selection {
-                                    id: selection.id,
-                                    start: snapshot.anchor_after(emoji_shortcode_start),
-                                    end: snapshot.anchor_before(selection.start),
-                                    reversed: selection.reversed,
-                                    goal: selection.goal,
-                                },
-                                0,
-                            ));
+                // Remove shortcode from buffer
+                edits.push((
+                    emoji_shortcode_start..selection.start,
+                    "".to_string().into(),
+                ));
+                new_selections.push((
+                    Selection {
+                        id: selection.id,
+                        start: snapshot.anchor_after(emoji_shortcode_start),
+                        end: snapshot.anchor_before(selection.start),
+                        reversed: selection.reversed,
+                        goal: selection.goal,
+                    },
+                    0,
+                ));
 
-                            // Insert emoji
-                            let selection_start_anchor = snapshot.anchor_after(selection.start);
-                            new_selections.push((selection.map(|_| selection_start_anchor), 0));
-                            edits.push((selection.start..selection.end, emoji.to_string().into()));
+                // Insert emoji
+                let selection_start_anchor = snapshot.anchor_after(selection.start);
+                new_selections.push((selection.map(|_| selection_start_anchor), 0));
+                edits.push((selection.start..selection.end, emoji.to_string().into()));
 
-                            continue;
-                        }
-                    }
-                }
+                continue;
             }
 
             // If not handling any auto-close operation, then just replace the selected
@@ -4303,12 +4289,11 @@ 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);
-                }
+            {
+                on_type_format_task.detach_and_log_err(cx);
             }
 
             let editor_settings = EditorSettings::get_global(cx);
@@ -5274,10 +5259,10 @@ impl Editor {
                 }
 
                 let language = buffer.language()?;
-                if let Some(restrict_to_languages) = restrict_to_languages {
-                    if !restrict_to_languages.contains(language) {
-                        return None;
-                    }
+                if let Some(restrict_to_languages) = restrict_to_languages
+                    && !restrict_to_languages.contains(language)
+                {
+                    return None;
                 }
                 Some((
                     excerpt_id,
@@ -5605,15 +5590,15 @@ 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() {
-                    for response in provider_responses {
-                        completions.extend(response.completions);
-                        is_incomplete = is_incomplete || response.is_incomplete;
-                    }
-                    if completion_settings.words == WordsCompletionMode::Fallback {
-                        words = Task::ready(BTreeMap::default());
-                    }
+            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;
+                }
+                if completion_settings.words == WordsCompletionMode::Fallback {
+                    words = Task::ready(BTreeMap::default());
                 }
             }
 
@@ -5718,21 +5703,21 @@ impl Editor {
 
             editor
                 .update_in(cx, |editor, window, cx| {
-                    if editor.focus_handle.is_focused(window) {
-                        if let Some(menu) = menu {
-                            *editor.context_menu.borrow_mut() =
-                                Some(CodeContextMenu::Completions(menu));
-
-                            crate::hover_popover::hide_hover(editor, cx);
-                            if editor.show_edit_predictions_in_menu() {
-                                editor.update_visible_edit_prediction(window, cx);
-                            } else {
-                                editor.discard_edit_prediction(false, cx);
-                            }
+                    if editor.focus_handle.is_focused(window)
+                        && let Some(menu) = menu
+                    {
+                        *editor.context_menu.borrow_mut() =
+                            Some(CodeContextMenu::Completions(menu));
 
-                            cx.notify();
-                            return;
+                        crate::hover_popover::hide_hover(editor, cx);
+                        if editor.show_edit_predictions_in_menu() {
+                            editor.update_visible_edit_prediction(window, cx);
+                        } else {
+                            editor.discard_edit_prediction(false, cx);
                         }
+
+                        cx.notify();
+                        return;
                     }
 
                     if editor.completion_tasks.len() <= 1 {
@@ -6079,11 +6064,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 {
-                        task_context_task =
-                            Self::build_tasks_context(&project, &buffer, buffer_row, tasks, cx);
-                    }
+                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, {
@@ -6148,14 +6133,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;
-                    }
+                    )
+                {
+                    return task;
                 }
 
                 Task::ready(Ok(()))
@@ -6342,21 +6327,20 @@ impl Editor {
                         .read(cx)
                         .excerpt_containing(editor.selections.newest_anchor().head(), cx)
                 })?;
-                if let Some((_, excerpted_buffer, excerpt_range)) = excerpt {
-                    if excerpted_buffer == *buffer {
-                        let all_edits_within_excerpt = buffer.read_with(cx, |buffer, _| {
-                            let excerpt_range = excerpt_range.to_offset(buffer);
-                            buffer
-                                .edited_ranges_for_transaction::<usize>(transaction)
-                                .all(|range| {
-                                    excerpt_range.start <= range.start
-                                        && excerpt_range.end >= range.end
-                                })
-                        })?;
+                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
+                            .edited_ranges_for_transaction::<usize>(transaction)
+                            .all(|range| {
+                                excerpt_range.start <= range.start && excerpt_range.end >= range.end
+                            })
+                    })?;
 
-                        if all_edits_within_excerpt {
-                            return Ok(());
-                        }
+                    if all_edits_within_excerpt {
+                        return Ok(());
                     }
                 }
             }
@@ -7779,10 +7763,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 {
-                    self.edit_prediction_indent_conflict = false;
-                }
+            if let Some((_, indent)) = indents.iter().next()
+                && indent.len == cursor_point.column
+            {
+                self.edit_prediction_indent_conflict = false;
             }
         }
 
@@ -9531,10 +9515,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 {
-                completion_provider.selection_changed(None, window, cx);
-            }
+        if let Some(CodeContextMenu::Completions(_)) = &context_menu
+            && let Some(completion_provider) = &self.completion_provider
+        {
+            completion_provider.selection_changed(None, window, cx);
         }
         context_menu
     }
@@ -9639,10 +9623,10 @@ impl Editor {
                 s.select_ranges(tabstop.ranges.iter().rev().cloned());
             });
 
-            if let Some(choices) = &tabstop.choices {
-                if let Some(selection) = tabstop.ranges.first() {
-                    self.show_snippet_choices(choices, selection.clone(), cx)
-                }
+            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,
@@ -9776,10 +9760,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() {
-                        self.show_snippet_choices(choices, selection.clone(), cx);
-                    }
+                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
@@ -10176,10 +10160,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 {
-                        rows.start = rows.start.next_row();
-                    }
+                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() {
@@ -10357,11 +10341,11 @@ impl Editor {
                 MultiBufferRow(selection.end.row)
             };
 
-            if let Some(last_row_range) = row_ranges.last_mut() {
-                if start <= last_row_range.end {
-                    last_row_range.end = end;
-                    continue;
-                }
+            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,17 +15315,15 @@ 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) {
-                        let buffer_snapshot = buffer.read(cx).snapshot();
-                        let excerpt_end_row =
-                            Point::from_anchor(&excerpt_range.end, &buffer_snapshot).row;
-                        let last_row = buffer_snapshot.max_point().row;
-                        let lines_below = last_row.saturating_sub(excerpt_end_row);
-                        should_scroll_up = lines_below >= lines_to_expand;
-                    }
-                }
+            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;
+                let last_row = buffer_snapshot.max_point().row;
+                let lines_below = last_row.saturating_sub(excerpt_end_row);
+                should_scroll_up = lines_below >= lines_to_expand;
             }
         }
 
@@ -15426,10 +15408,10 @@ impl Editor {
         let selection = self.selections.newest::<usize>(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 {
-                active_group_id = Some(active_group.group_id);
-            }
+        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(
@@ -16674,10 +16656,10 @@ impl Editor {
 
             buffer
                 .update(cx, |buffer, cx| {
-                    if let Some(transaction) = transaction {
-                        if !buffer.is_singleton() {
-                            buffer.push_transaction(&transaction.0, cx);
-                        }
+                    if let Some(transaction) = transaction
+                        && !buffer.is_singleton()
+                    {
+                        buffer.push_transaction(&transaction.0, cx);
                     }
                     cx.notify();
                 })
@@ -16743,10 +16725,10 @@ impl Editor {
             buffer
                 .update(cx, |buffer, cx| {
                     // check if we need this
-                    if let Some(transaction) = transaction {
-                        if !buffer.is_singleton() {
-                            buffer.push_transaction(&transaction.0, cx);
-                        }
+                    if let Some(transaction) = transaction
+                        && !buffer.is_singleton()
+                    {
+                        buffer.push_transaction(&transaction.0, cx);
                     }
                     cx.notify();
                 })
@@ -17378,12 +17360,12 @@ 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 {
-                            to_fold.push(crease);
-                            if row <= range.start.row {
-                                break;
-                            }
+                    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,10 +18675,10 @@ impl Editor {
 
     pub fn working_directory(&self, cx: &App) -> Option<PathBuf> {
         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() {
-                    return Some(dir.to_owned());
-                }
+            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) {
@@ -18756,10 +18738,10 @@ impl Editor {
         _window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(path) = self.target_file_abs_path(cx) {
-            if let Some(path) = path.to_str() {
-                cx.write_to_clipboard(ClipboardItem::new_string(path.to_string()));
-            }
+        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()));
         }
     }
 
@@ -18769,10 +18751,10 @@ impl Editor {
         _window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(path) = self.target_file_path(cx) {
-            if let Some(path) = path.to_str() {
-                cx.write_to_clipboard(ClipboardItem::new_string(path.to_string()));
-            }
+        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()));
         }
     }
 
@@ -18841,22 +18823,20 @@ impl Editor {
         _: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        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() {
-                    cx.write_to_clipboard(ClipboardItem::new_string(name.to_string()));
-                }
-            }
+        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<Self>) {
-        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() {
-                    cx.write_to_clipboard(ClipboardItem::new_string(name.to_string()));
-                }
-            }
+        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()));
         }
     }
 
@@ -19126,10 +19106,10 @@ impl Editor {
         cx: &mut Context<Self>,
     ) {
         let selection = self.selections.newest::<Point>(cx).start.row + 1;
-        if let Some(file) = self.target_file(cx) {
-            if let Some(path) = file.path().to_str() {
-                cx.write_to_clipboard(ClipboardItem::new_string(format!("{path}:{selection}")));
-            }
+        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}")));
         }
     }
 
@@ -19769,10 +19749,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 {
-                    continue;
-                }
+            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() {
@@ -20064,16 +20044,16 @@ 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 {
-                        project.update(cx, |project, cx| {
-                            self.registered_buffers
-                                .entry(edited_buffer.read(cx).remote_id())
-                                .or_insert_with(|| {
-                                    project.register_buffer_with_language_servers(edited_buffer, cx)
-                                });
-                        });
-                    }
+                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())
+                            .or_insert_with(|| {
+                                project.register_buffer_with_language_servers(edited_buffer, cx)
+                            });
+                    });
                 }
                 cx.emit(EditorEvent::BufferEdited);
                 cx.emit(SearchEvent::MatchesInvalidated);
@@ -20083,10 +20063,10 @@ impl Editor {
                 }
 
                 if *singleton_buffer_edited {
-                    if let Some(buffer) = edited_buffer {
-                        if buffer.read(cx).file().is_none() {
-                            cx.emit(EditorEvent::TitleChanged);
-                        }
+                    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)]
@@ -20132,17 +20112,17 @@ 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 {
-                        update_uncommitted_diff_for_buffer(
-                            cx.entity(),
-                            project,
-                            [buffer.clone()],
-                            self.buffer.clone(),
-                            cx,
-                        )
-                        .detach();
-                    }
+                if self.buffer.read(cx).diff_for(buffer_id).is_none()
+                    && let Some(project) = &self.project
+                {
+                    update_uncommitted_diff_for_buffer(
+                        cx.entity(),
+                        project,
+                        [buffer.clone()],
+                        self.buffer.clone(),
+                        cx,
+                    )
+                    .detach();
                 }
                 self.update_lsp_data(false, Some(buffer_id), window, cx);
                 cx.emit(EditorEvent::ExcerptsAdded {
@@ -20746,11 +20726,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 {
-                        last_token.text.push_str(text);
-                        merged_with_last_token = true;
-                    }
+                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 {

crates/editor/src/element.rs πŸ”—

@@ -917,6 +917,10 @@ impl EditorElement {
         } else if cfg!(any(target_os = "linux", target_os = "freebsd"))
             && event.button == MouseButton::Middle
         {
+            #[allow(
+                clippy::collapsible_if,
+                reason = "The cfg-block below makes this a false positive"
+            )]
             if !text_hitbox.is_hovered(window) || editor.read_only(cx) {
                 return;
             }
@@ -1387,29 +1391,27 @@ impl EditorElement {
                     ref drop_cursor,
                     ref hide_drop_cursor,
                 } = editor.selection_drag_state
+                    && !hide_drop_cursor
+                    && (drop_cursor
+                        .start
+                        .cmp(&selection.start, &snapshot.buffer_snapshot)
+                        .eq(&Ordering::Less)
+                        || drop_cursor
+                            .end
+                            .cmp(&selection.end, &snapshot.buffer_snapshot)
+                            .eq(&Ordering::Greater))
                 {
-                    if !hide_drop_cursor
-                        && (drop_cursor
-                            .start
-                            .cmp(&selection.start, &snapshot.buffer_snapshot)
-                            .eq(&Ordering::Less)
-                            || drop_cursor
-                                .end
-                                .cmp(&selection.end, &snapshot.buffer_snapshot)
-                                .eq(&Ordering::Greater))
-                    {
-                        let drag_cursor_layout = SelectionLayout::new(
-                            drop_cursor.clone(),
-                            false,
-                            CursorShape::Bar,
-                            &snapshot.display_snapshot,
-                            false,
-                            false,
-                            None,
-                        );
-                        let absent_color = cx.theme().players().absent();
-                        selections.push((absent_color, vec![drag_cursor_layout]));
-                    }
+                    let drag_cursor_layout = SelectionLayout::new(
+                        drop_cursor.clone(),
+                        false,
+                        CursorShape::Bar,
+                        &snapshot.display_snapshot,
+                        false,
+                        false,
+                        None,
+                    );
+                    let absent_color = cx.theme().players().absent();
+                    selections.push((absent_color, vec![drag_cursor_layout]));
                 }
             }
 
@@ -1420,19 +1422,15 @@ 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()
-                                    {
-                                        *local_selection_style = cx
-                                            .theme()
-                                            .players()
-                                            .color_for_participant(participant_index.0);
-                                    }
-                                }
+                                && let Some((local_selection_style, _)) = selections.first_mut()
+                            {
+                                *local_selection_style = cx
+                                    .theme()
+                                    .players()
+                                    .color_for_participant(participant_index.0);
                             }
                         }
                         CollaboratorId::Agent => {
@@ -3518,33 +3516,33 @@ 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 {
-                        let margin = em_width * 2;
-                        if line_width + final_size.width + margin
-                            < editor_width + editor_margins.gutter.full_width()
-                            && !row_block_types.contains_key(&(row - 1))
-                            && element_height_in_lines == 1
-                        {
-                            x_offset = line_width + margin;
-                            row = row - 1;
-                            is_block = false;
-                            element_height_in_lines = 0;
-                            row_block_types.insert(row, is_block);
-                        } else {
-                            let max_offset = editor_width + editor_margins.gutter.full_width()
-                                - final_size.width;
-                            let min_offset = (x_target + em_width - final_size.width)
-                                .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);
+        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()
+                    && !row_block_types.contains_key(&(row - 1))
+                    && element_height_in_lines == 1
+                {
+                    x_offset = line_width + margin;
+                    row = row - 1;
+                    is_block = false;
+                    element_height_in_lines = 0;
+                    row_block_types.insert(row, is_block);
+                } else {
+                    let max_offset =
+                        editor_width + editor_margins.gutter.full_width() - final_size.width;
+                    let min_offset = (x_target + em_width - final_size.width)
+                        .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 {
@@ -3987,60 +3985,58 @@ 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) {
-                        let style = block.style();
-                        let width = match style {
-                            BlockStyle::Fixed => AvailableSpace::MinContent,
-                            BlockStyle::Flex => AvailableSpace::Definite(
-                                hitbox
-                                    .size
-                                    .width
-                                    .max(fixed_block_max_width)
-                                    .max(editor_margins.gutter.width + *scroll_width),
-                            ),
-                            BlockStyle::Sticky => AvailableSpace::Definite(hitbox.size.width),
-                        };
+        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,
+                BlockStyle::Flex => AvailableSpace::Definite(
+                    hitbox
+                        .size
+                        .width
+                        .max(fixed_block_max_width)
+                        .max(editor_margins.gutter.width + *scroll_width),
+                ),
+                BlockStyle::Sticky => AvailableSpace::Definite(hitbox.size.width),
+            };
 
-                        if let Some((element, element_size, _, x_offset)) = self.render_block(
-                            &block,
-                            width,
-                            focused_block.id,
-                            rows.end,
-                            snapshot,
-                            text_x,
-                            &rows,
-                            line_layouts,
-                            editor_margins,
-                            line_height,
-                            em_width,
-                            text_hitbox,
-                            editor_width,
-                            scroll_width,
-                            &mut resized_blocks,
-                            &mut row_block_types,
-                            selections,
-                            selected_buffer_ids,
-                            is_row_soft_wrapped,
-                            sticky_header_excerpt_id,
-                            window,
-                            cx,
-                        ) {
-                            blocks.push(BlockLayout {
-                                id: block.id(),
-                                x_offset,
-                                row: None,
-                                element,
-                                available_space: size(width, element_size.height.into()),
-                                style,
-                                overlaps_gutter: true,
-                                is_buffer_header: block.is_buffer_header(),
-                            });
-                        }
-                    }
-                }
+            if let Some((element, element_size, _, x_offset)) = self.render_block(
+                &block,
+                width,
+                focused_block.id,
+                rows.end,
+                snapshot,
+                text_x,
+                &rows,
+                line_layouts,
+                editor_margins,
+                line_height,
+                em_width,
+                text_hitbox,
+                editor_width,
+                scroll_width,
+                &mut resized_blocks,
+                &mut row_block_types,
+                selections,
+                selected_buffer_ids,
+                is_row_soft_wrapped,
+                sticky_header_excerpt_id,
+                window,
+                cx,
+            ) {
+                blocks.push(BlockLayout {
+                    id: block.id(),
+                    x_offset,
+                    row: None,
+                    element,
+                    available_space: size(width, element_size.height.into()),
+                    style,
+                    overlaps_gutter: true,
+                    is_buffer_header: block.is_buffer_header(),
+                });
             }
         }
 
@@ -4203,19 +4199,19 @@ impl EditorElement {
                 edit_prediction_popover_visible = true;
             }
 
-            if editor.context_menu_visible() {
-                if let Some(crate::ContextMenuOrigin::Cursor) = editor.context_menu_origin() {
-                    let (min_height_in_lines, max_height_in_lines) = editor
-                        .context_menu_options
-                        .as_ref()
-                        .map_or((3, 12), |options| {
-                            (options.min_entries_visible, options.max_entries_visible)
-                        });
+            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()
+                    .map_or((3, 12), |options| {
+                        (options.min_entries_visible, options.max_entries_visible)
+                    });
 
-                    min_menu_height += line_height * min_height_in_lines as f32 + POPOVER_Y_PADDING;
-                    max_menu_height += line_height * max_height_in_lines as f32 + POPOVER_Y_PADDING;
-                    context_menu_visible = true;
-                }
+                min_menu_height += line_height * min_height_in_lines as f32 + POPOVER_Y_PADDING;
+                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
@@ -5761,16 +5757,15 @@ 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()
                     .read(cx)
                     .all_diff_hunks_expanded()
-                {
-                    window.set_cursor_style(CursorStyle::PointingHand, hunk_hitbox);
-                }
+            {
+                window.set_cursor_style(CursorStyle::PointingHand, hunk_hitbox);
             }
         }
 
@@ -10152,10 +10147,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) {
-            snapshot = editor.snapshot(window, 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;

crates/editor/src/git/blame.rs πŸ”—

@@ -312,10 +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 {
-                    max_author_length = author_len;
-                }
+            if let Some(author_len) = author_len
+                && author_len > max_author_length
+            {
+                max_author_length = author_len;
             }
         }
 
@@ -416,20 +416,19 @@ impl GitBlame {
             if row_edits
                 .peek()
                 .map_or(true, |next_edit| next_edit.old.start >= old_end)
+                && let Some(entry) = cursor.item()
             {
-                if let Some(entry) = cursor.item() {
-                    if old_end > edit.old.end {
-                        new_entries.push(
-                            GitBlameEntry {
-                                rows: cursor.end() - edit.old.end,
-                                blame: entry.blame.clone(),
-                            },
-                            &(),
-                        );
-                    }
-
-                    cursor.next();
+                if old_end > edit.old.end {
+                    new_entries.push(
+                        GitBlameEntry {
+                            rows: cursor.end() - edit.old.end,
+                            blame: entry.blame.clone(),
+                        },
+                        &(),
+                    );
                 }
+
+                cursor.next();
             }
         }
         new_entries.append(cursor.suffix(), &());

crates/editor/src/hover_links.rs πŸ”—

@@ -418,24 +418,22 @@ pub fn update_inlay_link_and_hover_points(
                                     }
                                     if let Some((language_server_id, location)) =
                                         hovered_hint_part.location
+                                        && secondary_held
+                                        && !editor.has_pending_nonempty_selection()
                                     {
-                                        if secondary_held
-                                            && !editor.has_pending_nonempty_selection()
-                                        {
-                                            go_to_definition_updated = true;
-                                            show_link_definition(
-                                                shift_held,
-                                                editor,
-                                                TriggerPoint::InlayHint(
-                                                    highlight,
-                                                    location,
-                                                    language_server_id,
-                                                ),
-                                                snapshot,
-                                                window,
-                                                cx,
-                                            );
-                                        }
+                                        go_to_definition_updated = true;
+                                        show_link_definition(
+                                            shift_held,
+                                            editor,
+                                            TriggerPoint::InlayHint(
+                                                highlight,
+                                                location,
+                                                language_server_id,
+                                            ),
+                                            snapshot,
+                                            window,
+                                            cx,
+                                        );
                                     }
                                 }
                             }
@@ -766,10 +764,11 @@ 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() {
-            return Some(link.as_str().to_string());
-        }
+    if let Some(link) = finder.links(&text).next()
+        && link.start() == 0
+        && link.end() == text.len()
+    {
+        return Some(link.as_str().to_string());
     }
 
     None

crates/editor/src/hover_popover.rs πŸ”—

@@ -142,11 +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 {
-                        // Hover triggered from same location as last time. Don't show again.
-                        return true;
-                    }
+                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,13 +270,12 @@ 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;
-        }
+    {
+        return None;
     }
 
     let hover_popover_delay = EditorSettings::get_global(cx).hover_popover_delay;
@@ -717,59 +716,54 @@ 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::<Workspace>().flatten() {
-                workspace.update(cx, |workspace, cx| {
-                    let task = workspace.open_abs_path(
-                        PathBuf::from(uri.path()),
-                        OpenOptions {
-                            visible: Some(OpenVisible::None),
-                            ..Default::default()
-                        },
-                        window,
-                        cx,
-                    );
+    if let Ok(uri) = Url::parse(&link)
+        && uri.scheme() == "file"
+        && let Some(workspace) = window.root::<Workspace>().flatten()
+    {
+        workspace.update(cx, |workspace, cx| {
+            let task = workspace.open_abs_path(
+                PathBuf::from(uri.path()),
+                OpenOptions {
+                    visible: Some(OpenVisible::None),
+                    ..Default::default()
+                },
+                window,
+                cx,
+            );
 
-                    cx.spawn_in(window, async move |_, cx| {
-                        let item = task.await?;
-                        // Ruby LSP uses URLs with #L1,1-4,4
-                        // we'll just take the first number and assume it's a line number
-                        let Some(fragment) = uri.fragment() else {
-                            return anyhow::Ok(());
-                        };
-                        let mut accum = 0u32;
-                        for c in fragment.chars() {
-                            if c >= '0' && c <= '9' && accum < u32::MAX / 2 {
-                                accum *= 10;
-                                accum += c as u32 - '0' as u32;
-                            } else if accum > 0 {
-                                break;
-                            }
-                        }
-                        if accum == 0 {
-                            return Ok(());
-                        }
-                        let Some(editor) = cx.update(|_, cx| item.act_as::<Editor>(cx))? else {
-                            return Ok(());
-                        };
-                        editor.update_in(cx, |editor, window, cx| {
-                            editor.change_selections(
-                                Default::default(),
-                                window,
-                                cx,
-                                |selections| {
-                                    selections.select_ranges([text::Point::new(accum - 1, 0)
-                                        ..text::Point::new(accum - 1, 0)]);
-                                },
-                            );
-                        })
-                    })
-                    .detach_and_log_err(cx);
-                });
-                return;
-            }
-        }
+            cx.spawn_in(window, async move |_, cx| {
+                let item = task.await?;
+                // Ruby LSP uses URLs with #L1,1-4,4
+                // we'll just take the first number and assume it's a line number
+                let Some(fragment) = uri.fragment() else {
+                    return anyhow::Ok(());
+                };
+                let mut accum = 0u32;
+                for c in fragment.chars() {
+                    if c >= '0' && c <= '9' && accum < u32::MAX / 2 {
+                        accum *= 10;
+                        accum += c as u32 - '0' as u32;
+                    } else if accum > 0 {
+                        break;
+                    }
+                }
+                if accum == 0 {
+                    return Ok(());
+                }
+                let Some(editor) = cx.update(|_, cx| item.act_as::<Editor>(cx))? else {
+                    return Ok(());
+                };
+                editor.update_in(cx, |editor, window, cx| {
+                    editor.change_selections(Default::default(), window, cx, |selections| {
+                        selections.select_ranges([
+                            text::Point::new(accum - 1, 0)..text::Point::new(accum - 1, 0)
+                        ]);
+                    });
+                })
+            })
+            .detach_and_log_err(cx);
+        });
+        return;
     }
     cx.open_url(&link);
 }
@@ -839,20 +833,19 @@ impl HoverState {
     pub fn focused(&self, window: &mut Window, cx: &mut Context<Editor>) -> 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) {
-                    hover_popover_is_focused = true;
-                }
+            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 = true;
         }
         hover_popover_is_focused
     }

crates/editor/src/indent_guides.rs πŸ”—

@@ -168,11 +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 {
-                last_range.end = last_range.end.max(end);
-                continue;
-            }
+        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);
     }

crates/editor/src/inlay_hint_cache.rs πŸ”—

@@ -498,16 +498,14 @@ 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(
-                                                cached_hint_id.id(),
-                                                anchor,
-                                                cached_hint,
-                                            ));
-                                        }
+                                    {
+                                        to_insert.push(Inlay::hint(
+                                            cached_hint_id.id(),
+                                            anchor,
+                                            cached_hint,
+                                        ));
                                     }
                                     excerpt_cache.next();
                                 }
@@ -522,16 +520,16 @@ 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(
-                            cached_hint_id.id(),
-                            anchor,
-                            maybe_missed_cached_hint,
-                        ));
-                    }
+                {
+                    to_insert.push(Inlay::hint(
+                        cached_hint_id.id(),
+                        anchor,
+                        maybe_missed_cached_hint,
+                    ));
                 }
             }
         }
@@ -620,44 +618,44 @@ 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 {
-                    let hint_to_resolve = cached_hint.clone();
-                    let server_id = *server_id;
-                    cached_hint.resolve_state = ResolveState::Resolving;
-                    drop(guard);
-                    cx.spawn_in(window, async move |editor, cx| {
-                        let resolved_hint_task = editor.update(cx, |editor, cx| {
-                            let buffer = editor.buffer().read(cx).buffer(buffer_id)?;
-                            editor.semantics_provider.as_ref()?.resolve_inlay_hint(
-                                hint_to_resolve,
-                                buffer,
-                                server_id,
-                                cx,
-                            )
-                        })?;
-                        if let Some(resolved_hint_task) = resolved_hint_task {
-                            let mut resolved_hint =
-                                resolved_hint_task.await.context("hint resolve task")?;
-                            editor.read_with(cx, |editor, _| {
-                                if let Some(excerpt_hints) =
-                                    editor.inlay_hint_cache.hints.get(&excerpt_id)
+            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;
+                drop(guard);
+                cx.spawn_in(window, async move |editor, cx| {
+                    let resolved_hint_task = editor.update(cx, |editor, cx| {
+                        let buffer = editor.buffer().read(cx).buffer(buffer_id)?;
+                        editor.semantics_provider.as_ref()?.resolve_inlay_hint(
+                            hint_to_resolve,
+                            buffer,
+                            server_id,
+                            cx,
+                        )
+                    })?;
+                    if let Some(resolved_hint_task) = resolved_hint_task {
+                        let mut resolved_hint =
+                            resolved_hint_task.await.context("hint resolve task")?;
+                        editor.read_with(cx, |editor, _| {
+                            if let Some(excerpt_hints) =
+                                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)
+                                    && cached_hint.resolve_state == ResolveState::Resolving
                                 {
-                                    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 {
-                                            resolved_hint.resolve_state = ResolveState::Resolved;
-                                            *cached_hint = resolved_hint;
-                                        }
-                                    }
+                                    resolved_hint.resolve_state = ResolveState::Resolved;
+                                    *cached_hint = resolved_hint;
                                 }
-                            })?;
-                        }
+                            }
+                        })?;
+                    }
 
-                        anyhow::Ok(())
-                    })
-                    .detach_and_log_err(cx);
-                }
+                    anyhow::Ok(())
+                })
+                .detach_and_log_err(cx);
             }
         }
     }
@@ -990,8 +988,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 +997,6 @@ fn fetch_and_update_hints(
                             );
                         })
                     }
-                }
 
                 editor
                     .semantics_provider
@@ -1240,14 +1237,12 @@ 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));
-            }
+        {
+            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);

crates/editor/src/items.rs πŸ”—

@@ -930,10 +930,10 @@ impl Item for Editor {
             })?;
             buffer
                 .update(cx, |buffer, cx| {
-                    if let Some(transaction) = transaction {
-                        if !buffer.is_singleton() {
-                            buffer.push_transaction(&transaction.0, cx);
-                        }
+                    if let Some(transaction) = transaction
+                        && !buffer.is_singleton()
+                    {
+                        buffer.push_transaction(&transaction.0, cx);
                     }
                 })
                 .ok();
@@ -1374,36 +1374,33 @@ 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()
+            && 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::<EditorRestorationData>())
+                .and_then(|data| {
+                    let file = project::File::from_dyn(buffer.read(cx).file())?;
+                    data.entries.get(&file.abs_path(cx))
+                })
         {
-            if WorkspaceSettings::get(None, cx).restore_on_file_reopen {
-                if 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::<EditorRestorationData>())
-                    .and_then(|data| {
-                        let file = project::File::from_dyn(buffer.read(cx).file())?;
-                        data.entries.get(&file.abs_path(cx))
-                    })
-                {
-                    editor.fold_ranges(
-                        clip_ranges(&restoration_data.folds, snapshot),
-                        false,
-                        window,
-                        cx,
-                    );
-                    if !restoration_data.selections.is_empty() {
-                        editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
-                            s.select_ranges(clip_ranges(&restoration_data.selections, snapshot));
-                        });
-                    }
-                    let (top_row, offset) = restoration_data.scroll_position;
-                    let anchor = Anchor::in_buffer(
-                        *excerpt_id,
-                        buffer_id,
-                        snapshot.anchor_before(Point::new(top_row, 0)),
-                    );
-                    editor.set_scroll_anchor(ScrollAnchor { anchor, offset }, window, cx);
-                }
+            editor.fold_ranges(
+                clip_ranges(&restoration_data.folds, snapshot),
+                false,
+                window,
+                cx,
+            );
+            if !restoration_data.selections.is_empty() {
+                editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
+                    s.select_ranges(clip_ranges(&restoration_data.selections, snapshot));
+                });
             }
+            let (top_row, offset) = restoration_data.scroll_position;
+            let anchor = Anchor::in_buffer(
+                *excerpt_id,
+                buffer_id,
+                snapshot.anchor_before(Point::new(top_row, 0)),
+            );
+            editor.set_scroll_anchor(ScrollAnchor { anchor, offset }, window, cx);
         }
 
         editor

crates/editor/src/jsx_tag_auto_close.rs πŸ”—

@@ -51,12 +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 {
-                    jsx_open_tag_node = parent;
-                }
-            }
+        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,10 +283,8 @@ 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) {
-                            unclosed_open_tag_count -= 1;
-                        }
+                    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

crates/editor/src/lsp_ext.rs πŸ”—

@@ -147,16 +147,15 @@ pub fn lsp_tasks(
                             },
                             cx,
                         )
-                    }) {
-                        if 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 =
-                                        runnable.resolve_task(&id_base, &lsp_buffer_context)?;
-                                    Some((location, resolved_task))
-                                },
-                            ));
-                        }
+                    }) && 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 =
+                                    runnable.resolve_task(&id_base, &lsp_buffer_context)?;
+                                Some((location, resolved_task))
+                            },
+                        ));
                     }
                     lsp_tasks
                         .entry(source_kind)

crates/editor/src/movement.rs πŸ”—

@@ -510,10 +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) {
-                break;
-            }
+        if let Some(prev_ch) = prev_ch
+            && is_boundary(ch, prev_ch)
+        {
+            break;
         }
 
         offset -= ch.len_utf8();
@@ -562,13 +562,13 @@ 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 return_point_before_boundary {
-                    return map.clip_point(prev_offset.to_display_point(map), Bias::Right);
-                } else {
-                    break;
-                }
+        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;
@@ -603,13 +603,13 @@ 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 start_offset == offset {
-                    trail_offset = Some(offset);
-                } else {
-                    break;
-                }
+        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();
@@ -651,13 +651,13 @@ 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 start_offset == offset {
-                    trail_offset = Some(offset);
-                } else {
-                    break;
-                }
+        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();

crates/editor/src/rust_analyzer_ext.rs πŸ”—

@@ -285,11 +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() {
-                    cx.open_url(&local_url);
-                    return;
-                }
+            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 {

crates/editor/src/scroll.rs πŸ”—

@@ -703,20 +703,20 @@ impl Editor {
         if matches!(
             settings.defaults.soft_wrap,
             SoftWrap::PreferredLineLength | SoftWrap::Bounded
-        ) {
-            if (settings.defaults.preferred_line_length as f32) < visible_column_count {
-                visible_column_count = settings.defaults.preferred_line_length as f32;
-            }
+        ) && (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 {
-                current_position.x += self.gutter_dimensions.margin / last_position_map.em_advance;
-            }
+        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(
@@ -749,12 +749,10 @@ impl Editor {
 
         if let (Some(visible_lines), Some(visible_columns)) =
             (self.visible_line_count(), self.visible_column_count())
+            && newest_head.row() <= DisplayRow(screen_top.row().0 + visible_lines as u32)
+            && newest_head.column() <= screen_top.column() + visible_columns as u32
         {
-            if 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;
-            }
+            return Ordering::Equal;
         }
 
         Ordering::Greater

crates/editor/src/scroll/autoscroll.rs πŸ”—

@@ -116,12 +116,12 @@ 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. {
-                scroll_position.y += (bounds.top() - last_bounds.top()) / line_height;
-                if scroll_position.y < 0. {
-                    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 {

crates/editor/src/test.rs πŸ”—

@@ -184,10 +184,10 @@ pub fn editor_content_with_blocks(editor: &Entity<Editor>, 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)) {
-                        continue;
-                    }
+                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");

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

crates/eval/src/explorer.rs πŸ”—

@@ -46,27 +46,25 @@ 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 {
-                        found_files.push(path);
-                    }
-                }
-            }
+        } 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<String> {
-    if let Some(parent) = output_path.parent() {
-        if !parent.exists() {
-            fs::create_dir_all(parent).context(format!(
-                "Failed to create output directory: {}",
-                parent.display()
-            ))?;
-        }
+    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");

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::<FailedAssertion>() {
+            if let Err(err) = result
+                && !err.is::<FailedAssertion>() {
                     return Err(err);
                 }
-            }
 
             println!("{}Stopped", this.log_prefix);
 

crates/extension/src/extension.rs πŸ”—

@@ -178,16 +178,15 @@ 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")?
+            && s.name() == "zed:api-version"
         {
-            if s.name() == "zed:api-version" {
-                version = parse_wasm_extension_version_custom_section(s.data());
-                if version.is_none() {
-                    bail!(
-                        "extension {} has invalid zed:api-version section: {:?}",
-                        extension_id,
-                        s.data()
-                    );
-                }
+            version = parse_wasm_extension_version_custom_section(s.data());
+            if version.is_none() {
+                bail!(
+                    "extension {} has invalid zed:api-version section: {:?}",
+                    extension_id,
+                    s.data()
+                );
             }
         }
     }

crates/extension_host/src/extension_host.rs πŸ”—

@@ -93,10 +93,9 @@ pub fn is_version_compatible(
         .wasm_api_version
         .as_ref()
         .and_then(|wasm_api_version| SemanticVersion::from_str(wasm_api_version).ok())
+        && !is_supported_wasm_api_version(release_channel, wasm_api_version)
     {
-        if !is_supported_wasm_api_version(release_channel, wasm_api_version) {
-            return false;
-        }
+        return false;
     }
 
     true
@@ -292,19 +291,17 @@ 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() {
-                extension_index = index;
-                if let (Ok(Some(index_metadata)), Ok(Some(extensions_metadata))) =
-                    (index_metadata, extensions_metadata)
-                {
-                    if index_metadata
-                        .mtime
-                        .bad_is_greater_than(extensions_metadata.mtime)
-                    {
-                        extension_index_needs_rebuild = false;
-                    }
-                }
+        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)
+                && index_metadata
+                    .mtime
+                    .bad_is_greater_than(extensions_metadata.mtime)
+            {
+                extension_index_needs_rebuild = false;
             }
         }
 
@@ -392,10 +389,9 @@ impl ExtensionStore {
 
                         if let Some(path::Component::Normal(extension_dir_name)) =
                             event_path.components().next()
+                            && let Some(extension_id) = extension_dir_name.to_str()
                         {
-                            if let Some(extension_id) = extension_dir_name.to_str() {
-                                reload_tx.unbounded_send(Some(extension_id.into())).ok();
-                            }
+                            reload_tx.unbounded_send(Some(extension_id.into())).ok();
                         }
                     }
                 }
@@ -763,8 +759,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 +768,6 @@ impl ExtensionStore {
                                 )
                             });
                         }
-                    }
                 })
                 .ok();
             }
@@ -912,12 +907,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 {
-                        events.update(cx, |this, cx| {
-                            this.emit(extension::Event::ExtensionUninstalled(manifest.clone()), cx)
-                        });
-                    }
+                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)
+                    });
                 }
             })?;
 
@@ -997,12 +992,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) {
-                        events.update(cx, |this, cx| {
-                            this.emit(extension::Event::ExtensionInstalled(manifest.clone()), cx)
-                        });
-                    }
+                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)
+                    });
                 }
             })?;
 
@@ -1788,10 +1783,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() {
-                return;
-            }
+        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());

crates/extension_host/src/wasm_host.rs πŸ”—

@@ -701,16 +701,15 @@ 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")?
+            && s.name() == "zed:api-version"
         {
-            if s.name() == "zed:api-version" {
-                version = parse_wasm_extension_version_custom_section(s.data());
-                if version.is_none() {
-                    bail!(
-                        "extension {} has invalid zed:api-version section: {:?}",
-                        extension_id,
-                        s.data()
-                    );
-                }
+            version = parse_wasm_extension_version_custom_section(s.data());
+            if version.is_none() {
+                bail!(
+                    "extension {} has invalid zed:api-version section: {:?}",
+                    extension_id,
+                    s.data()
+                );
             }
         }
     }

crates/extensions_ui/src/extensions_ui.rs πŸ”—

@@ -1031,15 +1031,14 @@ impl ExtensionsPage {
                                 .read(cx)
                                 .extension_manifest_for_id(&extension_id)
                                 .cloned()
+                                && let Some(events) = extension::ExtensionEvents::try_global(cx)
                             {
-                                if let Some(events) = extension::ExtensionEvents::try_global(cx) {
-                                    events.update(cx, |this, cx| {
-                                        this.emit(
-                                            extension::Event::ConfigureExtensionRequested(manifest),
-                                            cx,
-                                        )
-                                    });
-                                }
+                                events.update(cx, |this, cx| {
+                                    this.emit(
+                                        extension::Event::ConfigureExtensionRequested(manifest),
+                                        cx,
+                                    )
+                                });
                             }
                         }
                     })

crates/file_finder/src/file_finder.rs πŸ”—

@@ -209,11 +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) {
-                self.init_modifiers = None;
-                window.dispatch_action(menu::Confirm.boxed_clone(), cx);
-            }
+        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);
         }
     }
 
@@ -323,27 +323,27 @@ 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()) {
-                    let path = match &m {
-                        Match::History { path, .. } => {
-                            let worktree_id = path.project.worktree_id;
-                            ProjectPath {
-                                worktree_id,
-                                path: Arc::clone(&path.project.path),
-                            }
+            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;
+                        ProjectPath {
+                            worktree_id,
+                            path: Arc::clone(&path.project.path),
                         }
-                        Match::Search(m) => ProjectPath {
-                            worktree_id: WorktreeId::from_usize(m.0.worktree_id),
-                            path: m.0.path.clone(),
-                        },
-                        Match::CreateNew(p) => p.clone(),
-                    };
-                    let open_task = workspace.update(cx, move |workspace, cx| {
-                        workspace.split_path_preview(path, false, Some(split_direction), window, cx)
-                    });
-                    open_task.detach_and_log_err(cx);
-                }
+                    }
+                    Match::Search(m) => ProjectPath {
+                        worktree_id: WorktreeId::from_usize(m.0.worktree_id),
+                        path: m.0.path.clone(),
+                    },
+                    Match::CreateNew(p) => p.clone(),
+                };
+                let open_task = workspace.update(cx, move |workspace, cx| {
+                    workspace.split_path_preview(path, false, Some(split_direction), window, cx)
+                });
+                open_task.detach_and_log_err(cx);
             }
         })
     }
@@ -675,17 +675,17 @@ 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 {
-                    let mut prev_position = panel_match.0.positions[0];
-                    for p in &panel_match.0.positions[1..] {
-                        if *p != prev_position + 1 {
-                            return false;
-                        }
-                        prev_position = *p;
+            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 {
+                        return false;
                     }
-                    return true;
+                    prev_position = *p;
                 }
+                return true;
             }
         }
 
@@ -1045,10 +1045,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 {
-                                path = Arc::from(absolute_path.as_path());
-                            }
+                        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 {
@@ -1078,23 +1078,21 @@ impl FileFinderDelegate {
                 ),
             };
 
-        if file_name_positions.is_empty() {
-            if 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) {
-                        full_path.replace_range(0..user_home_path.len(), "~");
-                        full_path_positions.retain_mut(|pos| {
-                            if *pos >= user_home_path.len() {
-                                *pos -= user_home_path.len();
-                                *pos += 1;
-                                true
-                            } else {
-                                false
-                            }
-                        })
+        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() && 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() {
+                        *pos -= user_home_path.len();
+                        *pos += 1;
+                        true
+                    } else {
+                        false
                     }
-                }
+                })
             }
         }
 
@@ -1242,14 +1240,13 @@ impl FileFinderDelegate {
 
     /// Skips first history match (that is displayed topmost) if it's currently opened.
     fn calculate_selected_index(&self, cx: &mut Context<Picker<Self>>) -> 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() {
-                    let elements_after_first = self.matches.len() - 1;
-                    if elements_after_first > 0 {
-                        return 1;
-                    }
-                }
+        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;
             }
         }
 
@@ -1310,10 +1307,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 {
-                    return vec![first_non_history_index - 1];
-                }
+            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,69 +1433,101 @@ impl PickerDelegate for FileFinderDelegate {
         window: &mut Window,
         cx: &mut Context<Picker<FileFinderDelegate>>,
     ) {
-        if let Some(m) = self.matches.get(self.selected_index()) {
-            if let Some(workspace) = self.workspace.upgrade() {
-                let open_task = workspace.update(cx, |workspace, cx| {
-                    let split_or_open =
-                        |workspace: &mut Workspace,
-                         project_path,
-                         window: &mut Window,
-                         cx: &mut Context<Workspace>| {
-                            let allow_preview =
-                                PreviewTabsSettings::get_global(cx).enable_preview_from_file_finder;
-                            if secondary {
-                                workspace.split_path_preview(
-                                    project_path,
-                                    allow_preview,
-                                    None,
-                                    window,
-                                    cx,
-                                )
-                            } else {
-                                workspace.open_path_preview(
-                                    project_path,
-                                    None,
-                                    true,
-                                    allow_preview,
-                                    true,
-                                    window,
-                                    cx,
-                                )
-                            }
-                        };
-                    match &m {
-                        Match::CreateNew(project_path) => {
-                            // Create a new file with the given filename
-                            if secondary {
-                                workspace.split_path_preview(
-                                    project_path.clone(),
-                                    false,
-                                    None,
-                                    window,
-                                    cx,
-                                )
-                            } else {
-                                workspace.open_path_preview(
-                                    project_path.clone(),
-                                    None,
-                                    true,
-                                    false,
-                                    true,
-                                    window,
-                                    cx,
-                                )
-                            }
+        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,
+                     project_path,
+                     window: &mut Window,
+                     cx: &mut Context<Workspace>| {
+                        let allow_preview =
+                            PreviewTabsSettings::get_global(cx).enable_preview_from_file_finder;
+                        if secondary {
+                            workspace.split_path_preview(
+                                project_path,
+                                allow_preview,
+                                None,
+                                window,
+                                cx,
+                            )
+                        } else {
+                            workspace.open_path_preview(
+                                project_path,
+                                None,
+                                true,
+                                allow_preview,
+                                true,
+                                window,
+                                cx,
+                            )
                         }
+                    };
+                match &m {
+                    Match::CreateNew(project_path) => {
+                        // Create a new file with the given filename
+                        if secondary {
+                            workspace.split_path_preview(
+                                project_path.clone(),
+                                false,
+                                None,
+                                window,
+                                cx,
+                            )
+                        } else {
+                            workspace.open_path_preview(
+                                project_path.clone(),
+                                None,
+                                true,
+                                false,
+                                true,
+                                window,
+                                cx,
+                            )
+                        }
+                    }
 
-                        Match::History { path, .. } => {
-                            let worktree_id = path.project.worktree_id;
-                            if workspace
-                                .project()
-                                .read(cx)
-                                .worktree_for_id(worktree_id, cx)
-                                .is_some()
-                            {
-                                split_or_open(
+                    Match::History { path, .. } => {
+                        let worktree_id = path.project.worktree_id;
+                        if workspace
+                            .project()
+                            .read(cx)
+                            .worktree_for_id(worktree_id, cx)
+                            .is_some()
+                        {
+                            split_or_open(
+                                workspace,
+                                ProjectPath {
+                                    worktree_id,
+                                    path: Arc::clone(&path.project.path),
+                                },
+                                window,
+                                cx,
+                            )
+                        } else {
+                            match path.absolute.as_ref() {
+                                Some(abs_path) => {
+                                    if secondary {
+                                        workspace.split_abs_path(
+                                            abs_path.to_path_buf(),
+                                            false,
+                                            window,
+                                            cx,
+                                        )
+                                    } else {
+                                        workspace.open_abs_path(
+                                            abs_path.to_path_buf(),
+                                            OpenOptions {
+                                                visible: Some(OpenVisible::None),
+                                                ..Default::default()
+                                            },
+                                            window,
+                                            cx,
+                                        )
+                                    }
+                                }
+                                None => split_or_open(
                                     workspace,
                                     ProjectPath {
                                         worktree_id,
@@ -1506,88 +1535,52 @@ impl PickerDelegate for FileFinderDelegate {
                                     },
                                     window,
                                     cx,
-                                )
-                            } else {
-                                match path.absolute.as_ref() {
-                                    Some(abs_path) => {
-                                        if secondary {
-                                            workspace.split_abs_path(
-                                                abs_path.to_path_buf(),
-                                                false,
-                                                window,
-                                                cx,
-                                            )
-                                        } else {
-                                            workspace.open_abs_path(
-                                                abs_path.to_path_buf(),
-                                                OpenOptions {
-                                                    visible: Some(OpenVisible::None),
-                                                    ..Default::default()
-                                                },
-                                                window,
-                                                cx,
-                                            )
-                                        }
-                                    }
-                                    None => split_or_open(
-                                        workspace,
-                                        ProjectPath {
-                                            worktree_id,
-                                            path: Arc::clone(&path.project.path),
-                                        },
-                                        window,
-                                        cx,
-                                    ),
-                                }
+                                ),
                             }
                         }
-                        Match::Search(m) => split_or_open(
-                            workspace,
-                            ProjectPath {
-                                worktree_id: WorktreeId::from_usize(m.0.worktree_id),
-                                path: m.0.path.clone(),
-                            },
-                            window,
-                            cx,
-                        ),
                     }
-                });
+                    Match::Search(m) => split_or_open(
+                        workspace,
+                        ProjectPath {
+                            worktree_id: WorktreeId::from_usize(m.0.worktree_id),
+                            path: m.0.path.clone(),
+                        },
+                        window,
+                        cx,
+                    ),
+                }
+            });
 
-                let row = self
-                    .latest_search_query
-                    .as_ref()
-                    .and_then(|query| query.path_position.row)
-                    .map(|row| row.saturating_sub(1));
-                let col = self
-                    .latest_search_query
-                    .as_ref()
-                    .and_then(|query| query.path_position.column)
-                    .unwrap_or(0)
-                    .saturating_sub(1);
-                let finder = self.file_finder.clone();
-
-                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::<Editor>() {
-                            active_editor
-                                .downgrade()
-                                .update_in(cx, |editor, window, cx| {
-                                    editor.go_to_singleton_buffer_point(
-                                        Point::new(row, col),
-                                        window,
-                                        cx,
-                                    );
-                                })
-                                .log_err();
-                        }
-                    }
-                    finder.update(cx, |_, cx| cx.emit(DismissEvent)).ok()?;
+            let row = self
+                .latest_search_query
+                .as_ref()
+                .and_then(|query| query.path_position.row)
+                .map(|row| row.saturating_sub(1));
+            let col = self
+                .latest_search_query
+                .as_ref()
+                .and_then(|query| query.path_position.column)
+                .unwrap_or(0)
+                .saturating_sub(1);
+            let finder = self.file_finder.clone();
+
+            cx.spawn_in(window, async move |_, cx| {
+                let item = open_task.await.notify_async_err(cx)?;
+                if let Some(row) = row
+                    && let Some(active_editor) = item.downcast::<Editor>()
+                {
+                    active_editor
+                        .downgrade()
+                        .update_in(cx, |editor, window, cx| {
+                            editor.go_to_singleton_buffer_point(Point::new(row, col), window, cx);
+                        })
+                        .log_err();
+                }
+                finder.update(cx, |_, cx| cx.emit(DismissEvent)).ok()?;
 
-                    Some(())
-                })
-                .detach();
-            }
+                Some(())
+            })
+            .detach();
         }
     }
 

crates/file_finder/src/open_path_prompt.rs πŸ”—

@@ -75,16 +75,16 @@ impl OpenPathDelegate {
                 ..
             } => {
                 let mut i = selected_match_index;
-                if let Some(user_input) = user_input {
-                    if !user_input.exists || !user_input.is_dir {
-                        if i == 0 {
-                            return Some(CandidateInfo {
-                                path: user_input.file.clone(),
-                                is_dir: false,
-                            });
-                        } else {
-                            i -= 1;
-                        }
+                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(),
+                            is_dir: false,
+                        });
+                    } else {
+                        i -= 1;
                     }
                 }
                 let id = self.string_matches.get(i)?.candidate_id;

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<Mutex<Vec<PathEvent>>> = 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,13 +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 {
-                                    let mut target = target.clone();
-                                    target.extend(path_components);
-                                    path = target;
-                                    continue 'outer;
-                                }
+                            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);
@@ -1566,10 +1566,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() {
-                    state.current_branch_name = Some(first.to_string())
-                }
+            if let Some(first) = branches.first()
+                && state.current_branch_name.is_none()
+            {
+                state.current_branch_name = Some(first.to_string())
             }
             state
                 .branches

crates/fs/src/mac_watcher.rs πŸ”—

@@ -41,10 +41,9 @@ impl Watcher for MacWatcher {
         if let Some((watched_path, _)) = handles
             .range::<Path, _>((Bound::Unbounded, Bound::Included(path)))
             .next_back()
+            && path.starts_with(watched_path)
         {
-            if path.starts_with(watched_path) {
-                return Ok(());
-            }
+            return Ok(());
         }
 
         let (stream, handle) = EventStream::new(&[path], self.latency);

crates/fsevent/src/fsevent.rs πŸ”—

@@ -178,40 +178,39 @@ impl EventStream {
                     flags.contains(StreamFlags::USER_DROPPED)
                         || flags.contains(StreamFlags::KERNEL_DROPPED)
                 })
+                && let Some(last_valid_event_id) = state.last_valid_event_id.take()
             {
-                if let Some(last_valid_event_id) = state.last_valid_event_id.take() {
-                    fs::FSEventStreamStop(state.stream);
-                    fs::FSEventStreamInvalidate(state.stream);
-                    fs::FSEventStreamRelease(state.stream);
-
-                    let stream_context = fs::FSEventStreamContext {
-                        version: 0,
-                        info,
-                        retain: None,
-                        release: None,
-                        copy_description: None,
-                    };
-                    let stream = fs::FSEventStreamCreate(
-                        cf::kCFAllocatorDefault,
-                        Self::trampoline,
-                        &stream_context,
-                        state.paths,
-                        last_valid_event_id,
-                        state.latency.as_secs_f64(),
-                        fs::kFSEventStreamCreateFlagFileEvents
-                            | fs::kFSEventStreamCreateFlagNoDefer
-                            | fs::kFSEventStreamCreateFlagWatchRoot,
-                    );
-
-                    state.stream = stream;
-                    fs::FSEventStreamScheduleWithRunLoop(
-                        state.stream,
-                        cf::CFRunLoopGetCurrent(),
-                        cf::kCFRunLoopDefaultMode,
-                    );
-                    fs::FSEventStreamStart(state.stream);
-                    stream_restarted = true;
-                }
+                fs::FSEventStreamStop(state.stream);
+                fs::FSEventStreamInvalidate(state.stream);
+                fs::FSEventStreamRelease(state.stream);
+
+                let stream_context = fs::FSEventStreamContext {
+                    version: 0,
+                    info,
+                    retain: None,
+                    release: None,
+                    copy_description: None,
+                };
+                let stream = fs::FSEventStreamCreate(
+                    cf::kCFAllocatorDefault,
+                    Self::trampoline,
+                    &stream_context,
+                    state.paths,
+                    last_valid_event_id,
+                    state.latency.as_secs_f64(),
+                    fs::kFSEventStreamCreateFlagFileEvents
+                        | fs::kFSEventStreamCreateFlagNoDefer
+                        | fs::kFSEventStreamCreateFlagWatchRoot,
+                );
+
+                state.stream = stream;
+                fs::FSEventStreamScheduleWithRunLoop(
+                    state.stream,
+                    cf::CFRunLoopGetCurrent(),
+                    cf::kCFRunLoopDefaultMode,
+                );
+                fs::FSEventStreamStart(state.stream);
+                stream_restarted = true;
             }
 
             if !stream_restarted {

crates/git/src/blame.rs πŸ”—

@@ -289,14 +289,12 @@ fn parse_git_blame(output: &str) -> Result<Vec<BlameEntry>> {
             }
         };
 
-        if done {
-            if let Some(entry) = current_entry.take() {
-                index.insert(entry.sha, entries.len());
+        if done && let Some(entry) = current_entry.take() {
+            index.insert(entry.sha, entries.len());
 
-                // We only want annotations that have a commit.
-                if !entry.sha.is_zero() {
-                    entries.push(entry);
-                }
+            // We only want annotations that have a commit.
+            if !entry.sha.is_zero() {
+                entries.push(entry);
             }
         }
     }

crates/git/src/repository.rs πŸ”—

@@ -1447,12 +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/") {
-                                remote_branches.push(s.to_owned().into());
-                            }
-                        }
+                    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());
                     }
                 };
 
@@ -1574,10 +1573,9 @@ impl GitRepository for RealGitRepository {
                     Err(error) => {
                         if let Some(GitBinaryCommandError { status, .. }) =
                             error.downcast_ref::<GitBinaryCommandError>()
+                            && status.code() == Some(1)
                         {
-                            if status.code() == Some(1) {
-                                return Ok(false);
-                            }
+                            return Ok(false);
                         }
 
                         Err(error)

crates/git_hosting_providers/src/git_hosting_providers.rs πŸ”—

@@ -49,10 +49,10 @@ pub fn register_additional_providers(
 
 pub fn get_host_from_git_remote_url(remote_url: &str) -> Result<String> {
     maybe!({
-        if let Some(remote_url) = remote_url.strip_prefix("git@") {
-            if let Some((host, _)) = remote_url.trim_start_matches("git@").split_once(':') {
-                return Some(host.to_string());
-            }
+        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)

crates/git_ui/src/commit_modal.rs πŸ”—

@@ -135,11 +135,10 @@ impl CommitModal {
                             .as_ref()
                             .and_then(|repo| repo.read(cx).head_commit.as_ref())
                             .is_some()
+                            && !git_panel.amend_pending()
                         {
-                            if !git_panel.amend_pending() {
-                                git_panel.set_amend_pending(true, cx);
-                                git_panel.load_last_commit_message_if_empty(cx);
-                            }
+                            git_panel.set_amend_pending(true, cx);
+                            git_panel.load_last_commit_message_if_empty(cx);
                         }
                     }
                     ForceMode::Commit => {
@@ -195,12 +194,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() {
-                commit_editor.update(cx, |editor, cx| {
-                    editor.set_placeholder_text(suggested_commit_message, cx);
-                });
-            }
+        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);

crates/git_ui/src/git_panel.rs πŸ”—

@@ -926,19 +926,17 @@ 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::<ProjectDiff>(cx) {
-                if let Some(project_path) = project_diff.read(cx).active_path(cx) {
-                    if Some(&entry.repo_path)
-                        == git_repo
-                            .read(cx)
-                            .project_path_to_repo_path(&project_path, cx)
-                            .as_ref()
-                    {
-                        project_diff.focus_handle(cx).focus(window);
-                        project_diff.update(cx, |project_diff, cx| project_diff.autoscroll(cx));
-                        return None;
-                    }
-                }
+            if let Some(project_diff) = workspace.read(cx).active_item_as::<ProjectDiff>(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)
+                        .as_ref()
+            {
+                project_diff.focus_handle(cx).focus(window);
+                project_diff.update(cx, |project_diff, cx| project_diff.autoscroll(cx));
+                return None;
             };
 
             self.workspace
@@ -2514,10 +2512,11 @@ 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) {
-                new_co_authors.push(local_committer);
-            }
+        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,14 +2757,13 @@ 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);
-                }
+            {
+                pending_status_for_single_staged = Some(pending.target_status);
             }
         }
 

crates/git_ui/src/project_diff.rs πŸ”—

@@ -363,10 +363,10 @@ impl ProjectDiff {
             }
             _ => {}
         }
-        if editor.focus_handle(cx).contains_focused(window, cx) {
-            if self.multibuffer.read(cx).is_empty() {
-                self.focus_handle.focus(window)
-            }
+        if editor.focus_handle(cx).contains_focused(window, cx)
+            && self.multibuffer.read(cx).is_empty()
+        {
+            self.focus_handle.focus(window)
         }
     }
 

crates/go_to_line/src/cursor_position.rs πŸ”—

@@ -95,10 +95,8 @@ impl CursorPosition {
                 .ok()
                 .unwrap_or(true);
 
-            if !is_singleton {
-                if let Some(debounce) = debounce {
-                    cx.background_executor().timer(debounce).await;
-                }
+            if !is_singleton && let Some(debounce) = debounce {
+                cx.background_executor().timer(debounce).await;
             }
 
             editor
@@ -234,13 +232,11 @@ impl Render for CursorPosition {
                                 if let Some(editor) = workspace
                                     .active_item(cx)
                                     .and_then(|item| item.act_as::<Editor>(cx))
+                                    && let Some((_, buffer, _)) = editor.read(cx).active_excerpt(cx)
                                 {
-                                    if let Some((_, buffer, _)) = editor.read(cx).active_excerpt(cx)
-                                    {
-                                        workspace.toggle_modal(window, cx, |window, cx| {
-                                            crate::GoToLine::new(editor, buffer, window, cx)
-                                        })
-                                    }
+                                    workspace.toggle_modal(window, cx, |window, cx| {
+                                        crate::GoToLine::new(editor, buffer, window, cx)
+                                    })
                                 }
                             });
                         }

crates/go_to_line/src/go_to_line.rs πŸ”—

@@ -103,11 +103,11 @@ impl GoToLine {
                             return;
                         };
                         editor.update(cx, |editor, cx| {
-                            if let Some(placeholder_text) = editor.placeholder_text() {
-                                if editor.text(cx).is_empty() {
-                                    let placeholder_text = placeholder_text.to_string();
-                                    editor.set_text(placeholder_text, window, cx);
-                                }
+                            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);
                             }
                         });
                     }

crates/google_ai/src/google_ai.rs πŸ”—

@@ -106,10 +106,9 @@ pub fn validate_generate_content_request(request: &GenerateContentRequest) -> Re
         .contents
         .iter()
         .find(|content| content.role == Role::User)
+        && user_content.parts.is_empty()
     {
-        if user_content.parts.is_empty() {
-            bail!("User content must contain at least one part");
-        }
+        bail!("User content must contain at least one part");
     }
 
     Ok(())

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

crates/gpui/examples/input.rs πŸ”—

@@ -549,10 +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() {
-                window.paint_quad(cursor);
-            }
+        if focus_handle.is_focused(window)
+            && let Some(cursor) = prepaint.cursor.take()
+        {
+            window.paint_quad(cursor);
         }
 
         self.input.update(cx, |input, _cx| {

crates/gpui/src/app.rs πŸ”—

@@ -1516,12 +1516,11 @@ 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 = window_action_available;
         }
 
         action_available
@@ -1606,27 +1605,26 @@ 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())
-            {
-                for listener in global_listeners.iter().rev() {
-                    listener(action.as_any(), DispatchPhase::Bubble, self);
-                    if !self.propagate_event {
-                        break;
-                    }
+        {
+            for listener in global_listeners.iter().rev() {
+                listener(action.as_any(), DispatchPhase::Bubble, self);
+                if !self.propagate_event {
+                    break;
                 }
+            }
 
-                global_listeners.extend(
-                    self.global_action_listeners
-                        .remove(&action.as_any().type_id())
-                        .unwrap_or_default(),
-                );
-
+            global_listeners.extend(
                 self.global_action_listeners
-                    .insert(action.as_any().type_id(), global_listeners);
-            }
+                    .remove(&action.as_any().type_id())
+                    .unwrap_or_default(),
+            );
+
+            self.global_action_listeners
+                .insert(action.as_any().type_id(), global_listeners);
         }
     }
 

crates/gpui/src/app/context.rs πŸ”—

@@ -610,16 +610,16 @@ 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) {
-                            let event = FocusOutEvent {
-                                blurred: WeakFocusHandle {
-                                    id: blurred_id,
-                                    handles: Arc::downgrade(&cx.focus_handles),
-                                },
-                            };
-                            listener(view, event, window, cx)
-                        }
+                    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,
+                                handles: Arc::downgrade(&cx.focus_handles),
+                            },
+                        };
+                        listener(view, event, window, cx)
                     }
                 })
                 .is_ok()

crates/gpui/src/element.rs πŸ”—

@@ -603,10 +603,8 @@ impl AnyElement {
 
         self.0.prepaint(window, cx);
 
-        if !focus_assigned {
-            if let Some(focus_id) = window.next_frame.focus {
-                return FocusHandle::for_id(focus_id, &cx.focus_handles);
-            }
+        if !focus_assigned && let Some(focus_id) = window.next_frame.focus {
+            return FocusHandle::for_id(focus_id, &cx.focus_handles);
         }
 
         None

crates/gpui/src/elements/div.rs πŸ”—

@@ -286,21 +286,20 @@ 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::<T>() {
-                            (listener)(
-                                &DragMoveEvent {
-                                    event: event.clone(),
-                                    bounds: hitbox.bounds,
-                                    drag: PhantomData,
-                                    dragged_item: Arc::clone(&drag.value),
-                                },
-                                window,
-                                cx,
-                            );
-                        }
-                    }
+                if phase == DispatchPhase::Capture
+                    && let Some(drag) = &cx.active_drag
+                    && drag.value.as_ref().type_id() == TypeId::of::<T>()
+                {
+                    (listener)(
+                        &DragMoveEvent {
+                            event: event.clone(),
+                            bounds: hitbox.bounds,
+                            drag: PhantomData,
+                            dragged_item: Arc::clone(&drag.value),
+                        },
+                        window,
+                        cx,
+                    );
                 }
             }));
     }
@@ -1514,15 +1513,14 @@ 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(pending_mouse_down) = element_state.pending_mouse_down.as_ref()
-                        {
-                            *pending_mouse_down.borrow_mut() = None;
-                        }
-                        if let Some(clicked_state) = element_state.clicked_state.as_ref() {
-                            *clicked_state.borrow_mut() = ElementClickedState::default();
-                        }
+                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;
+                    }
+                    if let Some(clicked_state) = element_state.clicked_state.as_ref() {
+                        *clicked_state.borrow_mut() = ElementClickedState::default();
                     }
                 }
 
@@ -1530,35 +1528,35 @@ impl Interactivity {
                 // 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() {
-                        let mut handle = element_state
-                            .focus_handle
-                            .get_or_insert_with(|| cx.focus_handle())
-                            .clone()
-                            .tab_stop(false);
-
-                        if let Some(index) = self.tab_index {
-                            handle = handle.tab_index(index).tab_stop(true);
-                        }
-
-                        self.tracked_focus_handle = Some(handle);
+                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())
+                        .clone()
+                        .tab_stop(false);
+
+                    if let Some(index) = self.tab_index {
+                        handle = handle.tab_index(index).tab_stop(true);
                     }
+
+                    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)
+                } 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()
                 {
-                    if let Some(element_state) = element_state.as_mut() {
-                        self.scroll_offset = Some(
-                            element_state
-                                .scroll_offset
-                                .get_or_insert_with(Rc::default)
-                                .clone(),
-                        );
-                    }
+                    self.scroll_offset = Some(
+                        element_state
+                            .scroll_offset
+                            .get_or_insert_with(Rc::default)
+                            .clone(),
+                    );
                 }
 
                 let style = self.compute_style_internal(None, element_state.as_mut(), window, cx);
@@ -2031,26 +2029,27 @@ 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) {
-                            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 {
-                                    let drag = cx
-                                        .active_drag
-                                        .take()
-                                        .expect("checked for type drag state type above");
-
-                                    let mut can_drop = true;
-                                    if let Some(predicate) = &can_drop_predicate {
-                                        can_drop = predicate(drag.value.as_ref(), window, cx);
-                                    }
+                    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 {
+                                let drag = cx
+                                    .active_drag
+                                    .take()
+                                    .expect("checked for type drag state type above");
+
+                                let mut can_drop = true;
+                                if let Some(predicate) = &can_drop_predicate {
+                                    can_drop = predicate(drag.value.as_ref(), window, cx);
+                                }
 
-                                    if can_drop {
-                                        listener(drag.value.as_ref(), window, cx);
-                                        window.refresh();
-                                        cx.stop_propagation();
-                                    }
+                                if can_drop {
+                                    listener(drag.value.as_ref(), window, cx);
+                                    window.refresh();
+                                    cx.stop_propagation();
                                 }
                             }
                         }
@@ -2094,31 +2093,24 @@ 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()
-                                && (event.position - mouse_down.position).magnitude()
-                                    > DRAG_THRESHOLD
-                            {
-                                if 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)(
-                                        drag_value.as_ref(),
-                                        cursor_offset,
-                                        window,
-                                        cx,
-                                    );
-                                    cx.active_drag = Some(AnyDrag {
-                                        view: drag,
-                                        value: drag_value,
-                                        cursor_offset,
-                                        cursor_style: drag_cursor_style,
-                                    });
-                                    pending_mouse_down.take();
-                                    window.refresh();
-                                    cx.stop_propagation();
-                                }
-                            }
+                        if let Some(mouse_down) = pending_mouse_down.clone()
+                            && !cx.has_active_drag()
+                            && (event.position - mouse_down.position).magnitude() > DRAG_THRESHOLD
+                            && 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)(drag_value.as_ref(), cursor_offset, window, cx);
+                            cx.active_drag = Some(AnyDrag {
+                                view: drag,
+                                value: drag_value,
+                                cursor_offset,
+                                cursor_style: drag_cursor_style,
+                            });
+                            pending_mouse_down.take();
+                            window.refresh();
+                            cx.stop_propagation();
                         }
                     }
                 });
@@ -2428,33 +2420,32 @@ 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) {
-                    style.refine(in_focus_style);
-                }
+            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) {
-                    style.refine(focus_style);
-                }
+            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) {
-                            style.refine(&group_hover.style);
-                        }
-                    }
+                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) {
-                        style.refine(hover_style);
-                    }
+                if let Some(hover_style) = self.hover_style.as_ref()
+                    && hitbox.is_hovered(window)
+                {
+                    style.refine(hover_style);
                 }
             }
 
@@ -2468,12 +2459,10 @@ 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)
+                            && *state_type == drag.value.as_ref().type_id()
+                            && group_hitbox_id.is_hovered(window)
                         {
-                            if *state_type == drag.value.as_ref().type_id()
-                                && group_hitbox_id.is_hovered(window)
-                            {
-                                style.refine(&group_drag_style.style);
-                            }
+                            style.refine(&group_drag_style.style);
                         }
                     }
 
@@ -2495,16 +2484,16 @@ 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() {
-                    style.refine(&group.style)
-                }
+            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 {
-                    style.refine(active_style)
-                }
+            if let Some(active_style) = self.active_style.as_ref()
+                && clicked_state.element
+            {
+                style.refine(active_style)
             }
         }
 

crates/gpui/src/elements/image_cache.rs πŸ”—

@@ -297,10 +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() {
-                cx.drop_image(image, Some(window));
-            }
+        if let Some(mut item) = self.0.remove(&hash)
+            && let Some(Ok(image)) = item.get()
+        {
+            cx.drop_image(image, Some(window));
         }
     }
 

crates/gpui/src/elements/img.rs πŸ”—

@@ -379,13 +379,12 @@ 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() {
-                                            let mut element = loading();
-                                            replacement_id =
-                                                Some(element.request_layout(window, cx));
-                                            layout_state.replacement = Some(element);
-                                        }
+                                    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();

crates/gpui/src/elements/list.rs πŸ”—

@@ -732,46 +732,44 @@ impl StateInner {
                         item.element.prepaint_at(item_origin, window, cx);
                     });
 
-                    if let Some(autoscroll_bounds) = window.take_autoscroll() {
-                        if autoscroll {
-                            if autoscroll_bounds.top() < bounds.top() {
-                                return Err(ListOffset {
-                                    item_ix: item.index,
-                                    offset_in_item: autoscroll_bounds.top() - item_origin.y,
-                                });
-                            } else if autoscroll_bounds.bottom() > bounds.bottom() {
-                                let mut cursor = self.items.cursor::<Count>(&());
-                                cursor.seek(&Count(item.index), Bias::Right);
-                                let mut height = bounds.size.height - padding.top - padding.bottom;
-
-                                // Account for the height of the element down until the autoscroll bottom.
-                                height -= autoscroll_bounds.bottom() - item_origin.y;
-
-                                // Keep decreasing the scroll top until we fill all the available space.
-                                while height > Pixels::ZERO {
-                                    cursor.prev();
-                                    let Some(item) = cursor.item() else { break };
-
-                                    let size = item.size().unwrap_or_else(|| {
-                                        let mut item = render_item(cursor.start().0, window, cx);
-                                        let item_available_size = size(
-                                            bounds.size.width.into(),
-                                            AvailableSpace::MinContent,
-                                        );
-                                        item.layout_as_root(item_available_size, window, cx)
-                                    });
-                                    height -= size.height;
-                                }
-
-                                return Err(ListOffset {
-                                    item_ix: cursor.start().0,
-                                    offset_in_item: if height < Pixels::ZERO {
-                                        -height
-                                    } else {
-                                        Pixels::ZERO
-                                    },
+                    if let Some(autoscroll_bounds) = window.take_autoscroll()
+                        && autoscroll
+                    {
+                        if autoscroll_bounds.top() < bounds.top() {
+                            return Err(ListOffset {
+                                item_ix: item.index,
+                                offset_in_item: autoscroll_bounds.top() - item_origin.y,
+                            });
+                        } else if autoscroll_bounds.bottom() > bounds.bottom() {
+                            let mut cursor = self.items.cursor::<Count>(&());
+                            cursor.seek(&Count(item.index), Bias::Right);
+                            let mut height = bounds.size.height - padding.top - padding.bottom;
+
+                            // Account for the height of the element down until the autoscroll bottom.
+                            height -= autoscroll_bounds.bottom() - item_origin.y;
+
+                            // Keep decreasing the scroll top until we fill all the available space.
+                            while height > Pixels::ZERO {
+                                cursor.prev();
+                                let Some(item) = cursor.item() else { break };
+
+                                let size = item.size().unwrap_or_else(|| {
+                                    let mut item = render_item(cursor.start().0, window, cx);
+                                    let item_available_size =
+                                        size(bounds.size.width.into(), AvailableSpace::MinContent);
+                                    item.layout_as_root(item_available_size, window, cx)
                                 });
+                                height -= size.height;
                             }
+
+                            return Err(ListOffset {
+                                item_ix: cursor.start().0,
+                                offset_in_item: if height < Pixels::ZERO {
+                                    -height
+                                } else {
+                                    Pixels::ZERO
+                                },
+                            });
                         }
                     }
 

crates/gpui/src/elements/text.rs πŸ”—

@@ -356,12 +356,11 @@ impl TextLayout {
                         (None, "".into())
                     };
 
-                if let Some(text_layout) = element_state.0.borrow().as_ref() {
-                    if text_layout.size.is_some()
-                        && (wrap_width.is_none() || wrap_width == text_layout.wrap_width)
-                    {
-                        return text_layout.size.unwrap();
-                    }
+                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);
@@ -763,14 +762,13 @@ 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)
-                        }
+                    {
+                        window.set_cursor_style(crate::CursorStyle::PointingHand, hitbox)
                     }
 
                     let text_layout = text_layout.clone();
@@ -803,13 +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();
-                                }
+                            {
+                                mouse_down.set(Some(mouse_down_index));
+                                window.refresh();
                             }
                         });
                     }

crates/gpui/src/keymap/binding.rs πŸ”—

@@ -53,10 +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()) {
-                        keystroke.key = key.to_string();
-                    }
+                if keystroke.key.chars().count() == 1
+                    && let Some(key) = equivalents.get(&keystroke.key.chars().next().unwrap())
+                {
+                    keystroke.key = key.to_string();
                 }
             }
         }

crates/gpui/src/platform/blade/blade_renderer.rs πŸ”—

@@ -434,24 +434,24 @@ 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) {
-                log::error!("GPU hung");
-                #[cfg(target_os = "linux")]
-                if self.gpu.device_information().driver_name == "radv" {
-                    log::error!(
-                        "there's a known bug with amdgpu/radv, try setting ZED_PATH_SAMPLE_COUNT=0 as a workaround"
-                    );
-                    log::error!(
-                        "if that helps you're running into https://github.com/zed-industries/zed/issues/26143"
-                    );
-                }
+        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" {
                 log::error!(
-                    "your device information is: {:?}",
-                    self.gpu.device_information()
+                    "there's a known bug with amdgpu/radv, try setting ZED_PATH_SAMPLE_COUNT=0 as a workaround"
+                );
+                log::error!(
+                    "if that helps you're running into https://github.com/zed-industries/zed/issues/26143"
                 );
-                while !self.gpu.wait_for(&last_sp, MAX_FRAME_TIME_MS) {}
             }
+            log::error!(
+                "your device information is: {:?}",
+                self.gpu.device_information()
+            );
+            while !self.gpu.wait_for(&last_sp, MAX_FRAME_TIME_MS) {}
         }
     }
 

crates/gpui/src/platform/linux/wayland/client.rs πŸ”—

@@ -359,13 +359,13 @@ impl WaylandClientStatePtr {
             }
             changed
         };
-        if changed {
-            if let Some(mut callback) = state.common.callbacks.keyboard_layout_change.take() {
-                drop(state);
-                callback();
-                state = client.borrow_mut();
-                state.common.callbacks.keyboard_layout_change = Some(callback);
-            }
+
+        if changed && let Some(mut callback) = state.common.callbacks.keyboard_layout_change.take()
+        {
+            drop(state);
+            callback();
+            state = client.borrow_mut();
+            state.common.callbacks.keyboard_layout_change = Some(callback);
         }
     }
 
@@ -373,15 +373,15 @@ impl WaylandClientStatePtr {
         let mut client = self.get_client();
         let mut state = client.borrow_mut();
         let closed_window = state.windows.remove(surface_id).unwrap();
-        if let Some(window) = state.mouse_focused_window.take() {
-            if !window.ptr_eq(&closed_window) {
-                state.mouse_focused_window = Some(window);
-            }
+        if let Some(window) = state.mouse_focused_window.take()
+            && !window.ptr_eq(&closed_window)
+        {
+            state.mouse_focused_window = Some(window);
         }
-        if let Some(window) = state.keyboard_focused_window.take() {
-            if !window.ptr_eq(&closed_window) {
-                state.keyboard_focused_window = Some(window);
-            }
+        if let Some(window) = state.keyboard_focused_window.take()
+            && !window.ptr_eq(&closed_window)
+        {
+            state.keyboard_focused_window = Some(window);
         }
         if state.windows.is_empty() {
             state.common.signal.stop();
@@ -1784,17 +1784,17 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
                             drop(state);
                             window.handle_input(input);
                         }
-                    } else if let Some(discrete) = discrete {
-                        if let Some(window) = state.mouse_focused_window.clone() {
-                            let input = PlatformInput::ScrollWheel(ScrollWheelEvent {
-                                position: state.mouse_location.unwrap(),
-                                delta: ScrollDelta::Lines(discrete),
-                                modifiers: state.modifiers,
-                                touch_phase: TouchPhase::Moved,
-                            });
-                            drop(state);
-                            window.handle_input(input);
-                        }
+                    } else if let Some(discrete) = discrete
+                        && let Some(window) = state.mouse_focused_window.clone()
+                    {
+                        let input = PlatformInput::ScrollWheel(ScrollWheelEvent {
+                            position: state.mouse_location.unwrap(),
+                            delta: ScrollDelta::Lines(discrete),
+                            modifiers: state.modifiers,
+                            touch_phase: TouchPhase::Moved,
+                        });
+                        drop(state);
+                        window.handle_input(input);
                     }
                 }
             }

crates/gpui/src/platform/linux/wayland/cursor.rs πŸ”—

@@ -45,10 +45,11 @@ impl Cursor {
     }
 
     fn set_theme_internal(&mut self, theme_name: Option<String>) {
-        if let Some(loaded_theme) = self.loaded_theme.as_ref() {
-            if loaded_theme.name == theme_name && loaded_theme.scaled_size == self.scaled_size {
-                return;
-            }
+        if let Some(loaded_theme) = self.loaded_theme.as_ref()
+            && loaded_theme.name == theme_name
+            && loaded_theme.scaled_size == self.scaled_size
+        {
+            return;
         }
         let result = if let Some(theme_name) = theme_name.as_ref() {
             CursorTheme::load_from_name(

crates/gpui/src/platform/linux/wayland/window.rs πŸ”—

@@ -713,21 +713,20 @@ impl WaylandWindowStatePtr {
     }
 
     pub fn handle_input(&self, input: PlatformInput) {
-        if let Some(ref mut fun) = self.callbacks.borrow_mut().input {
-            if !fun(input.clone()).propagate {
-                return;
-            }
+        if let Some(ref mut fun) = self.callbacks.borrow_mut().input
+            && !fun(input.clone()).propagate
+        {
+            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);
             }
         }
     }

crates/gpui/src/platform/linux/x11/client.rs πŸ”—

@@ -565,10 +565,10 @@ impl X11Client {
                                     events.push(last_keymap_change_event);
                                 }
 
-                                if let Some(last_press) = last_key_press.as_ref() {
-                                    if last_press.detail == key_press.detail {
-                                        continue;
-                                    }
+                                if let Some(last_press) = last_key_press.as_ref()
+                                    && last_press.detail == key_press.detail
+                                {
+                                    continue;
                                 }
 
                                 if let Some(Event::KeyRelease(key_release)) =
@@ -2035,12 +2035,11 @@ fn xdnd_get_supported_atom(
         ),
     )
     .log_with_level(Level::Warn)
+        && let Some(atoms) = reply.value32()
     {
-        if let Some(atoms) = reply.value32() {
-            for atom in atoms {
-                if xdnd_is_atom_supported(atom, supported_atoms) {
-                    return atom;
-                }
+        for atom in atoms {
+            if xdnd_is_atom_supported(atom, supported_atoms) {
+                return atom;
             }
         }
     }
@@ -2411,11 +2410,13 @@ fn legacy_get_randr_scale_factor(connection: &XCBConnection, root: u32) -> Optio
     let mut crtc_infos: HashMap<randr::Crtc, randr::GetCrtcInfoReply> = HashMap::default();
     let mut valid_outputs: HashSet<randr::Output> = HashSet::new();
     for (crtc, cookie) in crtc_cookies {
-        if let Ok(reply) = cookie.reply() {
-            if reply.width > 0 && reply.height > 0 && !reply.outputs.is_empty() {
-                crtc_infos.insert(crtc, reply.clone());
-                valid_outputs.extend(&reply.outputs);
-            }
+        if let Ok(reply) = cookie.reply()
+            && reply.width > 0
+            && reply.height > 0
+            && !reply.outputs.is_empty()
+        {
+            crtc_infos.insert(crtc, reply.clone());
+            valid_outputs.extend(&reply.outputs);
         }
     }
 

crates/gpui/src/platform/linux/x11/clipboard.rs πŸ”—

@@ -1120,25 +1120,25 @@ impl Drop for Clipboard {
                 log::error!("Failed to flush the clipboard window. Error: {}", e);
                 return;
             }
-            if let Some(global_cb) = global_cb {
-                if let Err(e) = global_cb.server_handle.join() {
-                    // Let's try extracting the error message
-                    let message;
-                    if let Some(msg) = e.downcast_ref::<&'static str>() {
-                        message = Some((*msg).to_string());
-                    } else if let Some(msg) = e.downcast_ref::<String>() {
-                        message = Some(msg.clone());
-                    } else {
-                        message = None;
-                    }
-                    if let Some(message) = message {
-                        log::error!(
-                            "The clipboard server thread panicked. Panic message: '{}'",
-                            message,
-                        );
-                    } else {
-                        log::error!("The clipboard server thread panicked.");
-                    }
+            if let Some(global_cb) = global_cb
+                && let Err(e) = global_cb.server_handle.join()
+            {
+                // Let's try extracting the error message
+                let message;
+                if let Some(msg) = e.downcast_ref::<&'static str>() {
+                    message = Some((*msg).to_string());
+                } else if let Some(msg) = e.downcast_ref::<String>() {
+                    message = Some(msg.clone());
+                } else {
+                    message = None;
+                }
+                if let Some(message) = message {
+                    log::error!(
+                        "The clipboard server thread panicked. Panic message: '{}'",
+                        message,
+                    );
+                } else {
+                    log::error!("The clipboard server thread panicked.");
                 }
             }
         }

crates/gpui/src/platform/linux/x11/window.rs πŸ”—

@@ -515,19 +515,19 @@ impl X11WindowState {
                     xcb.configure_window(x_window, &xproto::ConfigureWindowAux::new().x(x).y(y)),
                 )?;
             }
-            if let Some(titlebar) = params.titlebar {
-                if let Some(title) = titlebar.title {
-                    check_reply(
-                        || "X11 ChangeProperty8 on window title failed.",
-                        xcb.change_property8(
-                            xproto::PropMode::REPLACE,
-                            x_window,
-                            xproto::AtomEnum::WM_NAME,
-                            xproto::AtomEnum::STRING,
-                            title.as_bytes(),
-                        ),
-                    )?;
-                }
+            if let Some(titlebar) = params.titlebar
+                && let Some(title) = titlebar.title
+            {
+                check_reply(
+                    || "X11 ChangeProperty8 on window title failed.",
+                    xcb.change_property8(
+                        xproto::PropMode::REPLACE,
+                        x_window,
+                        xproto::AtomEnum::WM_NAME,
+                        xproto::AtomEnum::STRING,
+                        title.as_bytes(),
+                    ),
+                )?;
             }
             if params.kind == WindowKind::PopUp {
                 check_reply(
@@ -956,10 +956,10 @@ impl X11WindowStatePtr {
     }
 
     pub fn handle_input(&self, input: PlatformInput) {
-        if let Some(ref mut fun) = self.callbacks.borrow_mut().input {
-            if !fun(input.clone()).propagate {
-                return;
-            }
+        if let Some(ref mut fun) = self.callbacks.borrow_mut().input
+            && !fun(input.clone()).propagate
+        {
+            return;
         }
         if let PlatformInput::KeyDown(event) = input {
             // only allow shift modifier when inserting text
@@ -1068,15 +1068,14 @@ impl X11WindowStatePtr {
         }
 
         let mut callbacks = self.callbacks.borrow_mut();
-        if let Some((content_size, scale_factor)) = resize_args {
-            if let Some(ref mut fun) = callbacks.resize {
-                fun(content_size, scale_factor)
-            }
+        if let Some((content_size, scale_factor)) = resize_args
+            && let Some(ref mut fun) = callbacks.resize
+        {
+            fun(content_size, scale_factor)
         }
-        if !is_resize {
-            if let Some(ref mut fun) = callbacks.moved {
-                fun();
-            }
+
+        if !is_resize && let Some(ref mut fun) = callbacks.moved {
+            fun();
         }
 
         Ok(())

crates/gpui/src/platform/mac/open_type.rs πŸ”—

@@ -35,14 +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() {
-                keys.push(kCTFontCascadeListAttribute);
-                values.push(generate_fallback_array(
-                    fallbacks,
-                    font.native_font().as_concrete_TypeRef(),
-                ));
-            }
+        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,

crates/gpui/src/platform/mac/platform.rs πŸ”—

@@ -715,10 +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) {
-                                        result.push(path)
-                                    }
+                                if url.isFileURL() == YES
+                                    && let Ok(path) = ns_url_to_path(url)
+                                {
+                                    result.push(path)
                                 }
                             }
                             Some(result)
@@ -786,15 +786,16 @@ 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) {
-                                            let new_filename = OsStr::from_bytes(
-                                                &filename.as_bytes()
-                                                    [..chunks[0].len() + 1 + chunks[1].len()],
-                                            )
-                                            .to_owned();
-                                            result.set_file_name(&new_filename);
-                                        }
+                                    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()],
+                                        )
+                                        .to_owned();
+                                        result.set_file_name(&new_filename);
                                     }
                                     return result;
                                 })

crates/gpui/src/platform/mac/window.rs πŸ”—

@@ -1478,18 +1478,18 @@ 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() {
-                    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);
-                            return YES;
-                        }
-                        NO
-                    });
-                    if handled == Some(YES) {
+            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);
                         return YES;
                     }
+                    NO
+                });
+                if handled == Some(YES) {
+                    return YES;
                 }
             }
 
@@ -1624,10 +1624,10 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {
                     modifiers: prev_modifiers,
                     capslock: prev_capslock,
                 })) = &lock.previous_modifiers_changed_event
+                    && prev_modifiers == modifiers
+                    && prev_capslock == capslock
                 {
-                    if prev_modifiers == modifiers && prev_capslock == capslock {
-                        return;
-                    }
+                    return;
                 }
 
                 lock.previous_modifiers_changed_event = Some(event.clone());
@@ -1995,10 +1995,10 @@ extern "C" fn attributed_substring_for_proposed_range(
         let mut adjusted: Option<Range<usize>> = None;
 
         let selected_text = input_handler.text_for_range(range.clone(), &mut adjusted)?;
-        if let Some(adjusted) = adjusted {
-            if adjusted != range {
-                unsafe { (actual_range as *mut NSRange).write(NSRange::from(adjusted)) };
-            }
+        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];
@@ -2073,11 +2073,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 }))
+        && send_new_event(&window_state, event)
     {
-        if send_new_event(&window_state, event) {
-            window_state.lock().external_files_dragged = true;
-            return NSDragOperationCopy;
-        }
+        window_state.lock().external_files_dragged = true;
+        return NSDragOperationCopy;
     }
     NSDragOperationNone
 }

crates/gpui/src/platform/test/dispatcher.rs πŸ”—

@@ -78,11 +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 {
-                    self.state.lock().time = due_time;
-                    continue;
-                }
+            if let Some(due_time) = next_due_time
+                && due_time <= new_now
+            {
+                self.state.lock().time = due_time;
+                continue;
             }
             break;
         }

crates/gpui/src/platform/test/platform.rs πŸ”—

@@ -201,10 +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) {
-                            return;
-                        }
+                    if let Some(window) = window.as_ref()
+                        && Rc::ptr_eq(&previous_window.0, &window.0)
+                    {
+                        return;
                     }
                     previous_window.simulate_active_status_change(false);
                 }

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)

crates/gpui/src/platform/windows/platform.rs πŸ”—

@@ -821,14 +821,14 @@ fn file_save_dialog(
     window: Option<HWND>,
 ) -> Result<Option<PathBuf>> {
     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 {

crates/gpui/src/text_system.rs πŸ”—

@@ -366,15 +366,14 @@ 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
-                    && last_run.underline == run.underline
-                    && last_run.strikethrough == run.strikethrough
-                    && last_run.background_color == run.background_color
-                {
-                    last_run.len += run.len as u32;
-                    continue;
-                }
+            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
+            {
+                last_run.len += run.len as u32;
+                continue;
             }
             decoration_runs.push(DecorationRun {
                 len: run.len as u32,
@@ -492,14 +491,14 @@ 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() {
-                processed = true;
-                process_line(first_line.to_string().into());
-                process_line(second_line.to_string().into());
-                for line_text in split_lines {
-                    process_line(line_text.to_string().into());
-                }
+        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());
+            for line_text in split_lines {
+                process_line(line_text.to_string().into());
             }
         }
 
@@ -534,11 +533,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 {
-                    last_run.len += run.len;
-                    continue;
-                }
+            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,

crates/gpui/src/text_system/line.rs πŸ”—

@@ -292,10 +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) {
-                                finished_underline = current_underline.take();
-                            }
+                        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((
@@ -310,10 +310,10 @@ fn paint_line(
                                 },
                             ));
                         }
-                        if let Some((_, strikethrough_style)) = &mut current_strikethrough {
-                            if style_run.strikethrough.as_ref() != Some(strikethrough_style) {
-                                finished_strikethrough = current_strikethrough.take();
-                            }
+                        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((
@@ -509,10 +509,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) {
-                                finished_background = current_background.take();
-                            }
+                        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((

crates/gpui/src/text_system/line_layout.rs πŸ”—

@@ -185,10 +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 {
-                        break;
-                    }
+                if let Some(max_lines) = max_lines
+                    && boundaries.len() >= max_lines - 1
+                {
+                    break;
                 }
 
                 if let Some(last_candidate_ix) = last_candidate_ix.take() {

crates/gpui/src/view.rs πŸ”—

@@ -205,22 +205,21 @@ 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
-                            && element_state.cache_key.content_mask == content_mask
-                            && element_state.cache_key.text_style == text_style
-                            && !window.dirty_views.contains(&self.entity_id())
-                            && !window.refreshing
-                        {
-                            let prepaint_start = window.prepaint_index();
-                            window.reuse_prepaint(element_state.prepaint_range.clone());
-                            cx.entities
-                                .extend_accessed(&element_state.accessed_entities);
-                            let prepaint_end = window.prepaint_index();
-                            element_state.prepaint_range = prepaint_start..prepaint_end;
-
-                            return (None, element_state);
-                        }
+                    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())
+                        && !window.refreshing
+                    {
+                        let prepaint_start = window.prepaint_index();
+                        window.reuse_prepaint(element_state.prepaint_range.clone());
+                        cx.entities
+                            .extend_accessed(&element_state.accessed_entities);
+                        let prepaint_end = window.prepaint_index();
+                        element_state.prepaint_range = prepaint_start..prepaint_end;
+
+                        return (None, element_state);
                     }
 
                     let refreshing = mem::replace(&mut window.refreshing, true);

crates/gpui/src/window.rs πŸ”—

@@ -3401,16 +3401,16 @@ 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) {
-                        let event = FocusOutEvent {
-                            blurred: WeakFocusHandle {
-                                id: blurred_id,
-                                handles: Arc::downgrade(&cx.focus_handles),
-                            },
-                        };
-                        listener(event, window, cx)
-                    }
+                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,
+                            handles: Arc::downgrade(&cx.focus_handles),
+                        },
+                    };
+                    listener(event, window, cx)
                 }
                 true
             }));
@@ -3444,12 +3444,12 @@ impl Window {
             return true;
         }
 
-        if let Some(input) = keystroke.key_char {
-            if 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;
-            }
+        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,11 +3864,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() {
-                    input_handler.dispatch_input(&input, self, cx);
-                    self.platform_window.set_input_handler(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,15 +4309,15 @@ impl Window {
         cx: &mut App,
         f: impl FnOnce(&mut Option<T>, &mut Self) -> R,
     ) -> R {
-        if let Some(inspector_id) = _inspector_id {
-            if 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 {
-                    return inspector.update(cx, |inspector, _cx| {
-                        inspector.with_active_element_state(self, f)
-                    });
-                }
+        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 {
+                return inspector.update(cx, |inspector, _cx| {
+                    inspector.with_active_element_state(self, f)
+                });
             }
         }
         f(&mut None, self)
@@ -4389,15 +4389,13 @@ 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()
                     .find(|hitbox| hitbox.id == hitbox_id)
-                {
-                    self.paint_quad(crate::fill(hitbox.bounds, crate::rgba(0x61afef4d)));
-                }
+            {
+                self.paint_quad(crate::fill(hitbox.bounds, crate::rgba(0x61afef4d)));
             }
         }
     }

crates/gpui_macros/src/derive_inspector_reflection.rs πŸ”—

@@ -160,16 +160,14 @@ fn extract_doc_comment(attrs: &[Attribute]) -> Option<String> {
     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 {
-                        let line = lit_str.value();
-                        let line = line.strip_prefix(' ').unwrap_or(&line);
-                        doc_lines.push(line.to_string());
-                    }
-                }
-            }
+        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());
         }
     }
 

crates/gpui_macros/src/test.rs πŸ”—

@@ -152,28 +152,28 @@ fn generate_test_function(
                         }
                         _ => {}
                     }
-                } else if let Type::Reference(ty) = &*arg.ty {
-                    if 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()
-                        {
-                            let cx_varname = format_ident!("cx_{}", ix);
-                            cx_vars.extend(quote!(
-                                let mut #cx_varname = gpui::TestAppContext::build(
-                                    dispatcher.clone(),
-                                    Some(stringify!(#outer_fn_name)),
-                                );
-                            ));
-                            cx_teardowns.extend(quote!(
-                                dispatcher.run_until_parked();
-                                #cx_varname.executor().forbid_parking();
-                                #cx_varname.quit();
-                                dispatcher.run_until_parked();
-                            ));
-                            inner_fn_args.extend(quote!(&mut #cx_varname,));
-                            continue;
-                        }
+                } 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()
+                    {
+                        let cx_varname = format_ident!("cx_{}", ix);
+                        cx_vars.extend(quote!(
+                            let mut #cx_varname = gpui::TestAppContext::build(
+                                dispatcher.clone(),
+                                Some(stringify!(#outer_fn_name)),
+                            );
+                        ));
+                        cx_teardowns.extend(quote!(
+                            dispatcher.run_until_parked();
+                            #cx_varname.executor().forbid_parking();
+                            #cx_varname.quit();
+                            dispatcher.run_until_parked();
+                        ));
+                        inner_fn_args.extend(quote!(&mut #cx_varname,));
+                        continue;
                     }
                 }
             }
@@ -215,48 +215,48 @@ 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 {
-                        let last_segment = ty.path.segments.last();
-                        match last_segment.map(|s| s.ident.to_string()).as_deref() {
-                            Some("App") => {
-                                let cx_varname = format_ident!("cx_{}", ix);
-                                let cx_varname_lock = format_ident!("cx_{}_lock", ix);
-                                cx_vars.extend(quote!(
-                                    let mut #cx_varname = gpui::TestAppContext::build(
-                                       dispatcher.clone(),
-                                       Some(stringify!(#outer_fn_name))
-                                    );
-                                    let mut #cx_varname_lock = #cx_varname.app.borrow_mut();
-                                ));
-                                inner_fn_args.extend(quote!(&mut #cx_varname_lock,));
-                                cx_teardowns.extend(quote!(
+                } 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") => {
+                            let cx_varname = format_ident!("cx_{}", ix);
+                            let cx_varname_lock = format_ident!("cx_{}_lock", ix);
+                            cx_vars.extend(quote!(
+                                let mut #cx_varname = gpui::TestAppContext::build(
+                                   dispatcher.clone(),
+                                   Some(stringify!(#outer_fn_name))
+                                );
+                                let mut #cx_varname_lock = #cx_varname.app.borrow_mut();
+                            ));
+                            inner_fn_args.extend(quote!(&mut #cx_varname_lock,));
+                            cx_teardowns.extend(quote!(
                                     drop(#cx_varname_lock);
                                     dispatcher.run_until_parked();
                                     #cx_varname.update(|cx| { cx.background_executor().forbid_parking(); cx.quit(); });
                                     dispatcher.run_until_parked();
                                 ));
-                                continue;
-                            }
-                            Some("TestAppContext") => {
-                                let cx_varname = format_ident!("cx_{}", ix);
-                                cx_vars.extend(quote!(
-                                    let mut #cx_varname = gpui::TestAppContext::build(
-                                        dispatcher.clone(),
-                                        Some(stringify!(#outer_fn_name))
-                                    );
-                                ));
-                                cx_teardowns.extend(quote!(
-                                    dispatcher.run_until_parked();
-                                    #cx_varname.executor().forbid_parking();
-                                    #cx_varname.quit();
-                                    dispatcher.run_until_parked();
-                                ));
-                                inner_fn_args.extend(quote!(&mut #cx_varname,));
-                                continue;
-                            }
-                            _ => {}
+                            continue;
+                        }
+                        Some("TestAppContext") => {
+                            let cx_varname = format_ident!("cx_{}", ix);
+                            cx_vars.extend(quote!(
+                                let mut #cx_varname = gpui::TestAppContext::build(
+                                    dispatcher.clone(),
+                                    Some(stringify!(#outer_fn_name))
+                                );
+                            ));
+                            cx_teardowns.extend(quote!(
+                                dispatcher.run_until_parked();
+                                #cx_varname.executor().forbid_parking();
+                                #cx_varname.quit();
+                                dispatcher.run_until_parked();
+                            ));
+                            inner_fn_args.extend(quote!(&mut #cx_varname,));
+                            continue;
                         }
+                        _ => {}
                     }
                 }
             }

crates/html_to_markdown/src/markdown.rs πŸ”—

@@ -34,15 +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()
-                    || writer.markdown.ends_with(' ')
-                    || writer.markdown.ends_with('\n'))
-                {
-                    writer.push_str(" ");
-                }
-            }
+        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" {

crates/http_client/src/github.rs πŸ”—

@@ -77,10 +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:") {
-                *digest = stripped.to_owned();
-            }
+        if let Some(digest) = &mut asset.digest
+            && let Some(stripped) = digest.strip_prefix("sha256:")
+        {
+            *digest = stripped.to_owned();
         }
     });
     Ok(release)

crates/journal/src/journal.rs πŸ”—

@@ -170,23 +170,23 @@ 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::<Editor>().map(|editor| editor.downgrade()) {
-                    editor.update_in(cx, |editor, window, cx| {
-                        let len = editor.buffer().read(cx).len(cx);
-                        editor.change_selections(
-                            SelectionEffects::scroll(Autoscroll::center()),
-                            window,
-                            cx,
-                            |s| s.select_ranges([len..len]),
-                        );
-                        if len > 0 {
-                            editor.insert("\n\n", window, cx);
-                        }
-                        editor.insert(&entry_heading, window, cx);
+            if let Some(Some(Ok(item))) = opened.first()
+                && let Some(editor) = item.downcast::<Editor>().map(|editor| editor.downgrade())
+            {
+                editor.update_in(cx, |editor, window, cx| {
+                    let len = editor.buffer().read(cx).len(cx);
+                    editor.change_selections(
+                        SelectionEffects::scroll(Autoscroll::center()),
+                        window,
+                        cx,
+                        |s| s.select_ranges([len..len]),
+                    );
+                    if len > 0 {
                         editor.insert("\n\n", window, cx);
-                    })?;
-                }
+                    }
+                    editor.insert(&entry_heading, window, cx);
+                    editor.insert("\n\n", window, cx);
+                })?;
             }
 
             anyhow::Ok(())

crates/language/src/buffer.rs πŸ”—

@@ -1158,13 +1158,12 @@ 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);
-            }
+        {
+            merged_operations.push(operation);
         }
     }
 
@@ -1185,11 +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) {
-                merged_operations.remove(ix);
-                operation_to_undo = Some(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,10 +1423,10 @@ impl Buffer {
             .map(|info| info.language.clone())
             .collect();
 
-        if languages.is_empty() {
-            if let Some(buffer_language) = self.language() {
-                languages.push(buffer_language.clone());
-            }
+        if languages.is_empty()
+            && let Some(buffer_language) = self.language()
+        {
+            languages.push(buffer_language.clone());
         }
 
         languages
@@ -2589,10 +2588,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 {
-                        return;
-                    }
+                if let Some(set) = self.remote_selections.get(&lamport_timestamp.replica_id)
+                    && set.lamport_timestamp > lamport_timestamp
+                {
+                    return;
                 }
 
                 self.remote_selections.insert(
@@ -3365,8 +3364,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 {
@@ -3377,13 +3376,13 @@ impl BufferSnapshot {
                             false
                         }
                     },
-                ) {
-                    smallest_range_and_depth = Some((range, layer.depth));
-                    scope = Some(LanguageScope {
-                        language: layer.language.clone(),
-                        override_id: layer.override_id(offset, &self.text),
-                    });
-                }
+                )
+            {
+                smallest_range_and_depth = Some((range, layer.depth));
+                scope = Some(LanguageScope {
+                    language: layer.language.clone(),
+                    override_id: layer.override_id(offset, &self.text),
+                });
             }
         }
 
@@ -3499,17 +3498,17 @@ 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() {
-                        layer_result = right_node;
-                    }
+                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() {
-                    continue;
-                }
+            if let Some(previous_result) = &result
+                && previous_result.byte_range().len() < layer_result.byte_range().len()
+            {
+                continue;
             }
             result = Some(layer_result);
         }
@@ -4081,10 +4080,10 @@ impl BufferSnapshot {
         let mut result: Option<(Range<usize>, Range<usize>)> = 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()) {
-                    continue;
-                }
+            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,27 +4473,26 @@ 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()) {
-                                query_ix += 1;
-                            }
-                        }
+                    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 {
-                        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
-                            .peek()
-                            .and_then(|first_chunk| first_chunk.chars().next());
-                        // Skip empty and "words" starting with digits as a heuristic to reduce useless completions
-                        if !query.skip_digits
-                            || first_char.map_or(true, |first_char| !first_char.is_digit(10))
-                        {
-                            words.insert(word_text.collect(), word_range);
-                        }
+                } 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
+                        .peek()
+                        .and_then(|first_chunk| first_chunk.chars().next());
+                    // Skip empty and "words" starting with digits as a heuristic to reduce useless completions
+                    if !query.skip_digits
+                        || first_char.map_or(true, |first_char| !first_char.is_digit(10))
+                    {
+                        words.insert(word_text.collect(), word_range);
                     }
                 }
                 query_ix = 0;
@@ -4607,17 +4605,17 @@ 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() {
-                        let next_capture_end = capture.node.end_byte();
-                        if range.start < next_capture_end {
-                            highlights.stack.push((
-                                next_capture_end,
-                                highlights.highlight_maps[capture.grammar_index].get(capture.index),
-                            ));
-                        }
-                        highlights.next_capture.take();
+                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((
+                            next_capture_end,
+                            highlights.highlight_maps[capture.grammar_index].get(capture.index),
+                        ));
                     }
+                    highlights.next_capture.take();
                 }
             } else if let Some(snapshot) = self.buffer_snapshot {
                 let (captures, highlight_maps) = snapshot.get_highlights(self.range.clone());
@@ -4642,33 +4640,33 @@ 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 {
-                let mut diagnostic_endpoints = Vec::new();
-                for entry in buffer.diagnostics_in_range::<_, usize>(self.range.clone(), false) {
-                    diagnostic_endpoints.push(DiagnosticEndpoint {
-                        offset: entry.range.start,
-                        is_start: true,
-                        severity: entry.diagnostic.severity,
-                        is_unnecessary: entry.diagnostic.is_unnecessary,
-                        underline: entry.diagnostic.underline,
-                    });
-                    diagnostic_endpoints.push(DiagnosticEndpoint {
-                        offset: entry.range.end,
-                        is_start: false,
-                        severity: entry.diagnostic.severity,
-                        is_unnecessary: entry.diagnostic.is_unnecessary,
-                        underline: entry.diagnostic.underline,
-                    });
-                }
-                diagnostic_endpoints
-                    .sort_unstable_by_key(|endpoint| (endpoint.offset, !endpoint.is_start));
-                *diagnostics = diagnostic_endpoints.into_iter().peekable();
-                self.hint_depth = 0;
-                self.error_depth = 0;
-                self.warning_depth = 0;
-                self.information_depth = 0;
+        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 {
+                    offset: entry.range.start,
+                    is_start: true,
+                    severity: entry.diagnostic.severity,
+                    is_unnecessary: entry.diagnostic.is_unnecessary,
+                    underline: entry.diagnostic.underline,
+                });
+                diagnostic_endpoints.push(DiagnosticEndpoint {
+                    offset: entry.range.end,
+                    is_start: false,
+                    severity: entry.diagnostic.severity,
+                    is_unnecessary: entry.diagnostic.is_unnecessary,
+                    underline: entry.diagnostic.underline,
+                });
             }
+            diagnostic_endpoints
+                .sort_unstable_by_key(|endpoint| (endpoint.offset, !endpoint.is_start));
+            *diagnostics = diagnostic_endpoints.into_iter().peekable();
+            self.hint_depth = 0;
+            self.error_depth = 0;
+            self.warning_depth = 0;
+            self.information_depth = 0;
         }
     }
 
@@ -4779,11 +4777,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() {
-                    chunk_end = chunk_end.min(*parent_capture_end);
-                    highlight_id = Some(*parent_highlight_id);
-                }
+            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 =
@@ -4977,11 +4975,12 @@ 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 {
-                        range.end += 1;
-                        continue;
-                    }
+                if let Some(range) = &mut current_range
+                    && value == range.end
+                    && range.len() < max_len
+                {
+                    range.end += 1;
+                    continue;
                 }
 
                 let prev_range = current_range.clone();
@@ -5049,10 +5048,10 @@ impl CharClassifier {
             } else {
                 scope.word_characters()
             };
-            if let Some(characters) = characters {
-                if characters.contains(&c) {
-                    return CharKind::Word;
-                }
+            if let Some(characters) = characters
+                && characters.contains(&c)
+            {
+                return CharKind::Word;
             }
         }
 

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,10 +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() {
-                        result.push((offset..end_offset, highlight_id));
-                    }
+                if let Some(highlight_id) = chunk.syntax_highlight_id
+                    && !highlight_id.is_default()
+                {
+                    result.push((offset..end_offset, highlight_id));
                 }
                 offset = end_offset;
             }
@@ -1796,11 +1795,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 {
-                *grammar.highlight_map.lock() =
-                    HighlightMap::new(highlights_query.capture_names(), theme);
-            }
+        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);
         }
     }
 
@@ -1920,11 +1919,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 {
-                        disabled_ids = &disabled_ids[1..];
-                        is_enabled = false;
-                    }
+                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)
             })

crates/language/src/syntax_map.rs πŸ”—

@@ -414,42 +414,42 @@ impl SyntaxSnapshot {
             .collect::<Vec<_>>();
         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 {
-                let mut resolved_injection_ranges = Vec::new();
-                let mut cursor = self
-                    .layers
-                    .filter::<_, ()>(text, |summary| summary.contains_unknown_injections);
-                cursor.next();
-                while let Some(layer) = cursor.item() {
-                    let SyntaxLayerContent::Pending { language_name } = &layer.content else {
-                        unreachable!()
-                    };
-                    if registry
-                        .language_for_name_or_extension(language_name)
-                        .now_or_never()
-                        .and_then(|language| language.ok())
-                        .is_some()
-                    {
-                        let range = layer.range.to_offset(text);
-                        log::trace!("reparse range {range:?} for language {language_name:?}");
-                        resolved_injection_ranges.push(range);
-                    }
-
-                    cursor.next();
-                }
-                drop(cursor);
-
-                if !resolved_injection_ranges.is_empty() {
-                    self.reparse_with_ranges(
-                        text,
-                        root_language,
-                        resolved_injection_ranges,
-                        Some(&registry),
-                    );
+        if let Some(registry) = registry
+            && registry.version() != self.language_registry_version
+        {
+            let mut resolved_injection_ranges = Vec::new();
+            let mut cursor = self
+                .layers
+                .filter::<_, ()>(text, |summary| summary.contains_unknown_injections);
+            cursor.next();
+            while let Some(layer) = cursor.item() {
+                let SyntaxLayerContent::Pending { language_name } = &layer.content else {
+                    unreachable!()
+                };
+                if registry
+                    .language_for_name_or_extension(language_name)
+                    .now_or_never()
+                    .and_then(|language| language.ok())
+                    .is_some()
+                {
+                    let range = layer.range.to_offset(text);
+                    log::trace!("reparse range {range:?} for language {language_name:?}");
+                    resolved_injection_ranges.push(range);
                 }
-                self.language_registry_version = registry.version();
+
+                cursor.next();
+            }
+            drop(cursor);
+
+            if !resolved_injection_ranges.is_empty() {
+                self.reparse_with_ranges(
+                    text,
+                    root_language,
+                    resolved_injection_ranges,
+                    Some(&registry),
+                );
             }
+            self.language_registry_version = registry.version();
         }
 
         self.update_count += 1;
@@ -1065,10 +1065,10 @@ impl<'a> SyntaxMapCaptures<'a> {
     pub fn set_byte_range(&mut self, range: Range<usize>) {
         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 {
-                    continue;
-                }
+            if let Some(capture) = &layer.next_capture
+                && capture.node.end_byte() > range.start
+            {
+                continue;
             }
             layer.advance();
         }
@@ -1277,11 +1277,11 @@ fn join_ranges(
             (None, None) => break,
         };
 
-        if let Some(last) = result.last_mut() {
-            if range.start <= last.end {
-                last.end = last.end.max(range.end);
-                continue;
-            }
+        if let Some(last) = result.last_mut()
+            && range.start <= last.end
+        {
+            last.end = last.end.max(range.end);
+            continue;
         }
         result.push(range);
     }
@@ -1330,14 +1330,13 @@ 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()));
-            }
+        {
+            combined_injection_ranges.insert(language.id, (language, Vec::new()));
         }
     }
 
@@ -1357,10 +1356,11 @@ 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 {
-                    continue;
-                }
+            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()));

crates/language/src/text_diff.rs πŸ”—

@@ -189,11 +189,11 @@ fn tokenize(text: &str, language_scope: Option<LanguageScope>) -> 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) {
-                    token = Some(&text[start_ix..ix]);
-                    start_ix = ix;
-                }
+            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() {

crates/language_model/src/request.rs πŸ”—

@@ -221,36 +221,33 @@ 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"))
+                && let Some(type_str) = type_value.as_str()
+                && type_str.to_lowercase() == "text"
+                && let Some(text) = text_value.as_str()
             {
-                if let Some(type_str) = type_value.as_str() {
-                    if type_str.to_lowercase() == "text" {
-                        if let Some(text) = text_value.as_str() {
-                            return Ok(Self::Text(Arc::from(text)));
-                        }
-                    }
-                }
+                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 {
-                    // Only one field, and it's "text" (case-insensitive)
-                    if let Some(text) = value.as_str() {
-                        return Ok(Self::Text(Arc::from(text)));
-                    }
+            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 {
-                    // 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) {
-                            return Ok(Self::Image(image));
-                        }
-                    }
+            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()
+                    && let Some(image) = LanguageModelImage::from_json(image_obj)
+                {
+                    return Ok(Self::Image(image));
                 }
             }
 

crates/language_models/src/provider/anthropic.rs πŸ”—

@@ -633,11 +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 {
-                        last_message.content.extend(anthropic_message_content);
-                        continue;
-                    }
+                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

crates/language_models/src/provider/bedrock.rs πŸ”—

@@ -412,10 +412,10 @@ impl BedrockModel {
                     .region(Region::new(region))
                     .timeout_config(TimeoutConfig::disabled());
 
-                if let Some(endpoint_url) = endpoint {
-                    if !endpoint_url.is_empty() {
-                        config_builder = config_builder.endpoint_url(endpoint_url);
-                    }
+                if let Some(endpoint_url) = endpoint
+                    && !endpoint_url.is_empty()
+                {
+                    config_builder = config_builder.endpoint_url(endpoint_url);
                 }
 
                 match auth_method {
@@ -728,11 +728,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 {
-                        last_message.content.extend(bedrock_message_content);
-                        continue;
-                    }
+                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()

crates/language_models/src/provider/cloud.rs πŸ”—

@@ -597,15 +597,13 @@ 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())
                         .and_then(|plan| cloud_llm_client::Plan::from_str(plan).ok())
-                    {
-                        return Err(anyhow!(ModelRequestLimitReachedError { plan }));
-                    }
+                {
+                    return Err(anyhow!(ModelRequestLimitReachedError { plan }));
                 }
             } else if status == StatusCode::PAYMENT_REQUIRED {
                 return Err(anyhow!(PaymentRequiredError));
@@ -662,29 +660,29 @@ where
 
 impl From<ApiError> for LanguageModelCompletionError {
     fn from(error: ApiError) -> Self {
-        if let Ok(cloud_error) = serde_json::from_str::<CloudApiError>(&error.body) {
-            if 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") {
-                    error.status
-                } else {
-                    // If there's a status code in the code string (e.g. "upstream_http_429")
-                    // then use that; otherwise, see if the JSON contains a status code.
-                    cloud_error
-                        .code
-                        .strip_prefix("upstream_http_")
-                        .and_then(|code_str| code_str.parse::<u16>().ok())
-                        .and_then(|code| StatusCode::from_u16(code).ok())
-                        .unwrap_or(error.status)
-                };
+        if let Ok(cloud_error) = serde_json::from_str::<CloudApiError>(&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") {
+                error.status
+            } else {
+                // If there's a status code in the code string (e.g. "upstream_http_429")
+                // then use that; otherwise, see if the JSON contains a status code.
+                cloud_error
+                    .code
+                    .strip_prefix("upstream_http_")
+                    .and_then(|code_str| code_str.parse::<u16>().ok())
+                    .and_then(|code| StatusCode::from_u16(code).ok())
+                    .unwrap_or(error.status)
+            };
 
-                return LanguageModelCompletionError::UpstreamProviderError {
-                    message: cloud_error.message,
-                    status,
-                    retry_after: cloud_error.retry_after.map(Duration::from_secs_f64),
-                };
-            }
+            return LanguageModelCompletionError::UpstreamProviderError {
+                message: cloud_error.message,
+                status,
+                retry_after: cloud_error.retry_after.map(Duration::from_secs_f64),
+            };
         }
 
         let retry_after = None;

crates/language_selector/src/active_buffer_language.rs πŸ”—

@@ -28,10 +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() {
-                self.active_language = Some(Some(language.name()));
-            }
+        if let Some((_, buffer, _)) = editor.active_excerpt(cx)
+            && let Some(language) = buffer.read(cx).language()
+        {
+            self.active_language = Some(Some(language.name()));
         }
 
         cx.notify();

crates/language_tools/src/lsp_log.rs πŸ”—

@@ -254,35 +254,35 @@ 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() {
-                        let server_id = server.server_id();
-                        let weak_this = cx.weak_entity();
-                        this.copilot_log_subscription =
-                            Some(server.on_notification::<copilot::request::LogMessage, _>(
-                                move |params, cx| {
-                                    weak_this
-                                        .update(cx, |this, cx| {
-                                            this.add_language_server_log(
-                                                server_id,
-                                                MessageType::LOG,
-                                                &params.message,
-                                                cx,
-                                            );
-                                        })
-                                        .ok();
-                                },
-                            ));
-                        let name = LanguageServerName::new_static("copilot");
-                        this.add_language_server(
-                            LanguageServerKind::Global,
-                            server.server_id(),
-                            Some(name),
-                            None,
-                            Some(server.clone()),
-                            cx,
-                        );
-                    }
+                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 =
+                        Some(server.on_notification::<copilot::request::LogMessage, _>(
+                            move |params, cx| {
+                                weak_this
+                                    .update(cx, |this, cx| {
+                                        this.add_language_server_log(
+                                            server_id,
+                                            MessageType::LOG,
+                                            &params.message,
+                                            cx,
+                                        );
+                                    })
+                                    .ok();
+                            },
+                        ));
+                    let name = LanguageServerName::new_static("copilot");
+                    this.add_language_server(
+                        LanguageServerKind::Global,
+                        server.server_id(),
+                        Some(name),
+                        None,
+                        Some(server.clone()),
+                        cx,
+                    );
                 }
             })
         });
@@ -733,16 +733,14 @@ 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(&current_lsp) {
-                        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)
-                                }
-                                LogKind::Trace => this.show_trace_for_server(server_id, window, cx),
-                                LogKind::Logs => this.show_logs_for_server(server_id, window, cx),
-                                LogKind::ServerInfo => this.show_server_info(server_id, window, cx),
-                            }
+                    if !store.read(cx).language_servers.contains_key(&current_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),
+                            LogKind::Trace => this.show_trace_for_server(server_id, window, cx),
+                            LogKind::Logs => this.show_logs_for_server(server_id, window, cx),
+                            LogKind::ServerInfo => this.show_server_info(server_id, window, cx),
                         }
                     }
                 } else if let Some(server_id) = first_server_id_for_project {
@@ -776,21 +774,17 @@ 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() {
-                                        editor.fold_ranges(
-                                            vec![
-                                                last_offset + fold_offset..last_offset + text.len(),
-                                            ],
-                                            false,
-                                            window,
-                                            cx,
-                                        );
-                                    }
-                                }
+                                && fold_offset < text.len()
+                            {
+                                editor.fold_ranges(
+                                    vec![last_offset + fold_offset..last_offset + text.len()],
+                                    false,
+                                    window,
+                                    cx,
+                                );
                             }
 
                             if newest_cursor_is_at_end {
@@ -1311,14 +1305,14 @@ impl ToolbarItemView for LspLogToolbarItemView {
         _: &mut Window,
         cx: &mut Context<Self>,
     ) -> workspace::ToolbarItemLocation {
-        if let Some(item) = active_pane_item {
-            if let Some(log_view) = item.downcast::<LspLogView>() {
-                self.log_view = Some(log_view.clone());
-                self._log_view_subscription = Some(cx.observe(&log_view, |_, _, cx| {
-                    cx.notify();
-                }));
-                return ToolbarItemLocation::PrimaryLeft;
-            }
+        if let Some(item) = active_pane_item
+            && let Some(log_view) = item.downcast::<LspLogView>()
+        {
+            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;

crates/language_tools/src/syntax_tree_view.rs πŸ”—

@@ -103,12 +103,11 @@ impl SyntaxTreeView {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(item) = active_item {
-            if item.item_id() != cx.entity_id() {
-                if let Some(editor) = item.act_as::<Editor>(cx) {
-                    self.set_editor(editor, window, cx);
-                }
-            }
+        if let Some(item) = active_item
+            && item.item_id() != cx.entity_id()
+            && let Some(editor) = item.act_as::<Editor>(cx)
+        {
+            self.set_editor(editor, window, cx);
         }
     }
 
@@ -537,12 +536,12 @@ impl ToolbarItemView for SyntaxTreeToolbarItemView {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) -> ToolbarItemLocation {
-        if let Some(item) = active_pane_item {
-            if let Some(view) = item.downcast::<SyntaxTreeView>() {
-                self.tree_view = Some(view.clone());
-                self.subscription = Some(cx.observe_in(&view, window, |_, _, _, cx| cx.notify()));
-                return ToolbarItemLocation::PrimaryLeft;
-            }
+        if let Some(item) = active_pane_item
+            && let Some(view) = item.downcast::<SyntaxTreeView>()
+        {
+            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;

crates/languages/src/go.rs πŸ”—

@@ -131,19 +131,19 @@ 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() {
-                    remove_matching(&container_dir, |entry| {
-                        entry != binary_path && entry.file_name() != Some(OsStr::new("gobin"))
-                    })
-                    .await;
+            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"))
+                })
+                .await;
 
-                    return Ok(LanguageServerBinary {
-                        path: binary_path.to_path_buf(),
-                        arguments: server_binary_arguments(),
-                        env: None,
-                    });
-                }
+                return Ok(LanguageServerBinary {
+                    path: binary_path.to_path_buf(),
+                    arguments: server_binary_arguments(),
+                    env: None,
+                });
             }
         } else if let Some(path) = this
             .cached_server_binary(container_dir.clone(), delegate)

crates/languages/src/lib.rs πŸ”—

@@ -244,11 +244,8 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
     cx.observe_flag::<BasedPyrightFeatureFlag, _>({
         let languages = languages.clone();
         move |enabled, _| {
-            if enabled {
-                if let Some(adapter) = basedpyright_lsp_adapter.take() {
-                    languages
-                        .register_available_lsp_adapter(adapter.name(), move || adapter.clone());
-                }
+            if enabled && let Some(adapter) = basedpyright_lsp_adapter.take() {
+                languages.register_available_lsp_adapter(adapter.name(), move || adapter.clone());
             }
         }
     })

crates/languages/src/python.rs πŸ”—

@@ -338,31 +338,31 @@ 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() {
-                        // Check if this looks like a virtual environment
-                        if venv_dir.join("pyvenv.cfg").exists()
-                            || venv_dir.join("bin/activate").exists()
-                            || venv_dir.join("Scripts/activate.bat").exists()
-                        {
-                            // Set venvPath and venv at the root level
-                            // This matches the format of a pyrightconfig.json file
-                            if let Some(parent) = venv_dir.parent() {
-                                // Use relative path if the venv is inside the workspace
-                                let venv_path = if parent == adapter.worktree_root_path() {
-                                    ".".to_string()
-                                } else {
-                                    parent.to_string_lossy().into_owned()
-                                };
-                                object.insert("venvPath".to_string(), Value::String(venv_path));
-                            }
+                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()
+                        || venv_dir.join("Scripts/activate.bat").exists()
+                    {
+                        // Set venvPath and venv at the root level
+                        // This matches the format of a pyrightconfig.json file
+                        if let Some(parent) = venv_dir.parent() {
+                            // Use relative path if the venv is inside the workspace
+                            let venv_path = if parent == adapter.worktree_root_path() {
+                                ".".to_string()
+                            } else {
+                                parent.to_string_lossy().into_owned()
+                            };
+                            object.insert("venvPath".to_string(), Value::String(venv_path));
+                        }
 
-                            if let Some(venv_name) = venv_dir.file_name() {
-                                object.insert(
-                                    "venv".to_owned(),
-                                    Value::String(venv_name.to_string_lossy().into_owned()),
-                                );
-                            }
+                        if let Some(venv_name) = venv_dir.file_name() {
+                            object.insert(
+                                "venv".to_owned(),
+                                Value::String(venv_name.to_string_lossy().into_owned()),
+                            );
                         }
                     }
                 }
@@ -1519,31 +1519,31 @@ 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() {
-                        // Check if this looks like a virtual environment
-                        if venv_dir.join("pyvenv.cfg").exists()
-                            || venv_dir.join("bin/activate").exists()
-                            || venv_dir.join("Scripts/activate.bat").exists()
-                        {
-                            // Set venvPath and venv at the root level
-                            // This matches the format of a pyrightconfig.json file
-                            if let Some(parent) = venv_dir.parent() {
-                                // Use relative path if the venv is inside the workspace
-                                let venv_path = if parent == adapter.worktree_root_path() {
-                                    ".".to_string()
-                                } else {
-                                    parent.to_string_lossy().into_owned()
-                                };
-                                object.insert("venvPath".to_string(), Value::String(venv_path));
-                            }
+                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()
+                        || venv_dir.join("Scripts/activate.bat").exists()
+                    {
+                        // Set venvPath and venv at the root level
+                        // This matches the format of a pyrightconfig.json file
+                        if let Some(parent) = venv_dir.parent() {
+                            // Use relative path if the venv is inside the workspace
+                            let venv_path = if parent == adapter.worktree_root_path() {
+                                ".".to_string()
+                            } else {
+                                parent.to_string_lossy().into_owned()
+                            };
+                            object.insert("venvPath".to_string(), Value::String(venv_path));
+                        }
 
-                            if let Some(venv_name) = venv_dir.file_name() {
-                                object.insert(
-                                    "venv".to_owned(),
-                                    Value::String(venv_name.to_string_lossy().into_owned()),
-                                );
-                            }
+                        if let Some(venv_name) = venv_dir.file_name() {
+                            object.insert(
+                                "venv".to_owned(),
+                                Value::String(venv_name.to_string_lossy().into_owned()),
+                            );
                         }
                     }
                 }

crates/languages/src/rust.rs πŸ”—

@@ -598,12 +598,10 @@ 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);
-                }
+            {
+                variables.insert(RUST_PACKAGE_TASK_VARIABLE.clone(), package_name);
             }
             if let Some(path) = local_abs_path.as_ref()
                 && let Some((target, manifest_path)) =

crates/languages/src/typescript.rs πŸ”—

@@ -341,10 +341,10 @@ async fn detect_package_manager(
     fs: Arc<dyn Fs>,
     package_json_data: Option<PackageJsonData>,
 ) -> &'static str {
-    if let Some(package_json_data) = package_json_data {
-        if let Some(package_manager) = package_json_data.package_manager {
-            return 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";

crates/livekit_client/src/test.rs πŸ”—

@@ -736,14 +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) {
-                let executor = server.executor.clone();
-                let token = self.token.clone();
-                executor
-                    .spawn(async move { server.leave_room(token).await.ok() })
-                    .detach();
-            }
+        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();
         }
     }
 }

crates/markdown/src/markdown.rs πŸ”—

@@ -340,27 +340,26 @@ 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:") {
-                        let Some((mime_info, data)) = data_url.split_once(',') else {
-                            continue;
-                        };
-                        let Some((mime_type, encoding)) = mime_info.split_once(';') else {
-                            continue;
-                        };
-                        let Some(format) = ImageFormat::from_mime_type(mime_type) else {
-                            continue;
-                        };
-                        let is_base64 = encoding == "base64";
-                        if is_base64 {
-                            if 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);
-                            }
-                        }
+                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;
+                    };
+                    let Some((mime_type, encoding)) = mime_info.split_once(';') else {
+                        continue;
+                    };
+                    let Some(format) = ImageFormat::from_mime_type(mime_type) else {
+                        continue;
+                    };
+                    let is_base64 = encoding == "base64";
+                    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,13 +658,13 @@ 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(open_url) = on_open_url.as_ref() {
-                                open_url(pressed_link.destination_url, window, cx);
-                            } else {
-                                cx.open_url(&pressed_link.destination_url);
-                            }
+                    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 {
@@ -758,10 +757,10 @@ impl Element for MarkdownElement {
         let mut current_img_block_range: Option<Range<usize>> = None;
         for (range, event) in parsed_markdown.events.iter() {
             // Skip alt text for images that rendered
-            if let Some(current_img_block_range) = &current_img_block_range {
-                if current_img_block_range.end > range.end {
-                    continue;
-                }
+            if let Some(current_img_block_range) = &current_img_block_range
+                && current_img_block_range.end > range.end
+            {
+                continue;
             }
 
             match event {
@@ -1696,10 +1695,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() {
-                        return Err(line.source_end);
-                    }
+                if let Some(next_line) = lines.peek()
+                    && position.y < next_line.layout.bounds().top()
+                {
+                    return Err(line.source_end);
                 }
 
                 continue;

crates/markdown_preview/src/markdown_parser.rs πŸ”—

@@ -300,13 +300,12 @@ 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
-                                && last_style == &MarkdownHighlight::Style(style.clone())
-                            {
-                                last_range.end = text.len();
-                                new_highlight = false;
-                            }
+                        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((
@@ -579,10 +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() {
-                                    list_item.content.extend(block);
-                                }
+                            if let Some(block) = block
+                                && let Some(list_item) = items_stack.last_mut()
+                            {
+                                list_item.content.extend(block);
                             }
                         }
                     }

crates/markdown_preview/src/markdown_preview_view.rs πŸ”—

@@ -151,10 +151,9 @@ impl MarkdownPreviewView {
         if let Some(editor) = workspace
             .active_item(cx)
             .and_then(|item| item.act_as::<Editor>(cx))
+            && Self::is_markdown_file(&editor, cx)
         {
-            if Self::is_markdown_file(&editor, cx) {
-                return Some(editor);
-            }
+            return Some(editor);
         }
         None
     }
@@ -243,32 +242,30 @@ impl MarkdownPreviewView {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(item) = active_item {
-            if item.item_id() != cx.entity_id() {
-                if let Some(editor) = item.act_as::<Editor>(cx) {
-                    if Self::is_markdown_file(&editor, cx) {
-                        self.set_editor(editor, window, cx);
-                    }
-                }
-            }
+        if let Some(item) = active_item
+            && item.item_id() != cx.entity_id()
+            && let Some(editor) = item.act_as::<Editor>(cx)
+            && Self::is_markdown_file(&editor, cx)
+        {
+            self.set_editor(editor, window, cx);
         }
     }
 
     pub fn is_markdown_file<V>(editor: &Entity<Editor>, cx: &mut Context<V>) -> bool {
         let buffer = editor.read(cx).buffer().read(cx);
-        if let Some(buffer) = buffer.as_singleton() {
-            if let Some(language) = buffer.read(cx).language() {
-                return language.name() == "Markdown".into();
-            }
+        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<Editor>, window: &mut Window, cx: &mut Context<Self>) {
-        if let Some(active) = &self.active_editor {
-            if active.editor == editor {
-                return;
-            }
+        if let Some(active) = &self.active_editor
+            && active.editor == editor
+        {
+            return;
         }
 
         let subscription = cx.subscribe_in(
@@ -552,21 +549,20 @@ 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))
                                                 .and_then(|block: &ParsedMarkdownElement| {
                                                     block.source_range()
                                                 })
-                                            {
-                                                this.move_cursor_to_block(
-                                                    window,
-                                                    cx,
-                                                    source_range.start..source_range.start,
-                                                );
-                                            }
+                                        {
+                                            this.move_cursor_to_block(
+                                                window,
+                                                cx,
+                                                source_range.start..source_range.start,
+                                            );
                                         }
                                     },
                                 ))

crates/migrator/src/migrations/m_2025_06_16/settings.rs πŸ”—

@@ -40,20 +40,20 @@ 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 let (None, Some(quote_content)) = (column, key_node.child(0)) {
-                    column = Some(quote_content.start_position().column);
-                }
-                if let Some(string_content) = key_node.child(1) {
-                    let key = &contents[string_content.byte_range()];
-                    match key {
-                        // If it already has a source key, don't modify it
-                        "source" => return None,
-                        "command" => has_command = true,
-                        "settings" => has_settings = true,
-                        _ => other_keys += 1,
-                    }
+        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);
+            }
+            if let Some(string_content) = key_node.child(1) {
+                let key = &contents[string_content.byte_range()];
+                match key {
+                    // If it already has a source key, don't modify it
+                    "source" => return None,
+                    "command" => has_command = true,
+                    "settings" => has_settings = true,
+                    _ => other_keys += 1,
                 }
             }
         }

crates/migrator/src/migrations/m_2025_06_25/settings.rs πŸ”—

@@ -84,10 +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() == "," {
-                range_to_remove.start = prev_sibling.start_byte();
-            }
+        if let Some(prev_sibling) = pair_node.prev_sibling()
+            && prev_sibling.kind() == ","
+        {
+            range_to_remove.start = prev_sibling.start_byte();
         }
     }
 
@@ -123,10 +123,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()) {
-            range_to_remove.end += newline_pos + 1;
-        }
+    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()))

crates/migrator/src/migrations/m_2025_06_27/settings.rs πŸ”—

@@ -56,19 +56,18 @@ 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) {
-                    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();
-                        match key {
-                            "path" => path_value = Some(&contents[value_range]),
-                            "args" => args_value = Some(&contents[value_range]),
-                            "env" => env_value = Some(&contents[value_range]),
-                            _ => {}
-                        }
-                    }
+        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();
+                match key {
+                    "path" => path_value = Some(&contents[value_range]),
+                    "args" => args_value = Some(&contents[value_range]),
+                    "env" => env_value = Some(&contents[value_range]),
+                    _ => {}
                 }
             }
         }

crates/multi_buffer/src/anchor.rs πŸ”—

@@ -76,27 +76,26 @@ 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())
-                {
-                    let self_anchor = self.diff_base_anchor.filter(|a| base_text.can_resolve(a));
-                    let other_anchor = other.diff_base_anchor.filter(|a| base_text.can_resolve(a));
-                    return match (self_anchor, other_anchor) {
-                        (Some(a), Some(b)) => a.cmp(&b, base_text),
-                        (Some(_), None) => match other.text_anchor.bias {
-                            Bias::Left => Ordering::Greater,
-                            Bias::Right => Ordering::Less,
-                        },
-                        (None, Some(_)) => match self.text_anchor.bias {
-                            Bias::Left => Ordering::Less,
-                            Bias::Right => Ordering::Greater,
-                        },
-                        (None, None) => Ordering::Equal,
-                    };
-                }
+            {
+                let self_anchor = self.diff_base_anchor.filter(|a| base_text.can_resolve(a));
+                let other_anchor = other.diff_base_anchor.filter(|a| base_text.can_resolve(a));
+                return match (self_anchor, other_anchor) {
+                    (Some(a), Some(b)) => a.cmp(&b, base_text),
+                    (Some(_), None) => match other.text_anchor.bias {
+                        Bias::Left => Ordering::Greater,
+                        Bias::Right => Ordering::Less,
+                    },
+                    (None, Some(_)) => match self.text_anchor.bias {
+                        Bias::Left => Ordering::Less,
+                        Bias::Right => Ordering::Greater,
+                    },
+                    (None, None) => Ordering::Equal,
+                };
             }
         }
         Ordering::Equal
@@ -107,51 +106,49 @@ 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) {
-                return Self {
-                    buffer_id: self.buffer_id,
-                    excerpt_id: self.excerpt_id,
-                    text_anchor: self.text_anchor.bias_left(&excerpt.buffer),
-                    diff_base_anchor: self.diff_base_anchor.map(|a| {
-                        if let Some(base_text) = snapshot
-                            .diffs
-                            .get(&excerpt.buffer_id)
-                            .map(|diff| diff.base_text())
-                        {
-                            if a.buffer_id == Some(base_text.remote_id()) {
-                                return a.bias_left(base_text);
-                            }
-                        }
-                        a
-                    }),
-                };
-            }
+        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,
+                text_anchor: self.text_anchor.bias_left(&excerpt.buffer),
+                diff_base_anchor: self.diff_base_anchor.map(|a| {
+                    if let Some(base_text) = snapshot
+                        .diffs
+                        .get(&excerpt.buffer_id)
+                        .map(|diff| diff.base_text())
+                        && 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) {
-                return Self {
-                    buffer_id: self.buffer_id,
-                    excerpt_id: self.excerpt_id,
-                    text_anchor: self.text_anchor.bias_right(&excerpt.buffer),
-                    diff_base_anchor: self.diff_base_anchor.map(|a| {
-                        if let Some(base_text) = snapshot
-                            .diffs
-                            .get(&excerpt.buffer_id)
-                            .map(|diff| diff.base_text())
-                        {
-                            if a.buffer_id == Some(base_text.remote_id()) {
-                                return a.bias_right(base_text);
-                            }
-                        }
-                        a
-                    }),
-                };
-            }
+        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,
+                text_anchor: self.text_anchor.bias_right(&excerpt.buffer),
+                diff_base_anchor: self.diff_base_anchor.map(|a| {
+                    if let Some(base_text) = snapshot
+                        .diffs
+                        .get(&excerpt.buffer_id)
+                        .map(|diff| diff.base_text())
+                        && a.buffer_id == Some(base_text.remote_id())
+                    {
+                        return a.bias_right(base_text);
+                    }
+                    a
+                }),
+            };
         }
         *self
     }

crates/multi_buffer/src/multi_buffer.rs πŸ”—

@@ -1082,11 +1082,11 @@ impl MultiBuffer {
 
                 let mut ranges: Vec<Range<usize>> = Vec::new();
                 for edit in edits {
-                    if let Some(last_range) = ranges.last_mut() {
-                        if edit.range.start <= last_range.end {
-                            last_range.end = last_range.end.max(edit.range.end);
-                            continue;
-                        }
+                    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,25 +1212,24 @@ impl MultiBuffer {
             for range in buffer.edited_ranges_for_transaction_id::<D>(*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 {
-                            let excerpt_buffer_start =
-                                excerpt.range.context.start.summary::<D>(buffer);
-                            let excerpt_buffer_end = excerpt.range.context.end.summary::<D>(buffer);
-                            let excerpt_range = excerpt_buffer_start..excerpt_buffer_end;
-                            if excerpt_range.contains(&range.start)
-                                && excerpt_range.contains(&range.end)
-                            {
-                                let excerpt_start = D::from_text_summary(&cursor.start().text);
+                    if let Some(excerpt) = cursor.item()
+                        && excerpt.locator == *excerpt_id
+                    {
+                        let excerpt_buffer_start = excerpt.range.context.start.summary::<D>(buffer);
+                        let excerpt_buffer_end = excerpt.range.context.end.summary::<D>(buffer);
+                        let excerpt_range = excerpt_buffer_start..excerpt_buffer_end;
+                        if excerpt_range.contains(&range.start)
+                            && excerpt_range.contains(&range.end)
+                        {
+                            let excerpt_start = D::from_text_summary(&cursor.start().text);
 
-                                let mut start = excerpt_start;
-                                start.add_assign(&(range.start - excerpt_buffer_start));
-                                let mut end = excerpt_start;
-                                end.add_assign(&(range.end - excerpt_buffer_start));
+                            let mut start = excerpt_start;
+                            start.add_assign(&(range.start - excerpt_buffer_start));
+                            let mut end = excerpt_start;
+                            end.add_assign(&(range.end - excerpt_buffer_start));
 
-                                ranges.push(start..end);
-                                break;
-                            }
+                            ranges.push(start..end);
+                            break;
                         }
                     }
                 }
@@ -1251,25 +1250,25 @@ 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) {
-                for (buffer_id, buffer_transaction_id) in transaction.buffer_transactions {
-                    if let Some(destination_buffer_transaction_id) =
-                        destination.buffer_transactions.get(&buffer_id)
-                    {
-                        if let Some(state) = self.buffers.borrow().get(&buffer_id) {
-                            state.buffer.update(cx, |buffer, _| {
-                                buffer.merge_transactions(
-                                    buffer_transaction_id,
-                                    *destination_buffer_transaction_id,
-                                )
-                            });
-                        }
-                    } else {
-                        destination
-                            .buffer_transactions
-                            .insert(buffer_id, buffer_transaction_id);
+        } 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)
+                {
+                    if let Some(state) = self.buffers.borrow().get(&buffer_id) {
+                        state.buffer.update(cx, |buffer, _| {
+                            buffer.merge_transactions(
+                                buffer_transaction_id,
+                                *destination_buffer_transaction_id,
+                            )
+                        });
                     }
+                } else {
+                    destination
+                        .buffer_transactions
+                        .insert(buffer_id, buffer_transaction_id);
                 }
             }
         }
@@ -1562,11 +1561,11 @@ impl MultiBuffer {
             });
             let mut merged_ranges: Vec<ExcerptRange<Point>> = Vec::new();
             for range in expanded_ranges {
-                if let Some(last_range) = merged_ranges.last_mut() {
-                    if last_range.context.end >= range.context.start {
-                        last_range.context.end = range.context.end;
-                        continue;
-                    }
+                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)
             }
@@ -1794,25 +1793,25 @@ impl MultiBuffer {
             };
 
             if let Some((last_id, last)) = to_insert.last_mut() {
-                if let Some(new) = new {
-                    if 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(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 {
-                        last.context.end = last.context.end.max(existing_range.end);
-                        to_remove.push(*existing_id);
-                        self.snapshot
-                            .borrow_mut()
-                            .replaced_excerpts
-                            .insert(*existing_id, *last_id);
-                        existing_iter.next();
-                        continue;
-                    }
+                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
+                        .borrow_mut()
+                        .replaced_excerpts
+                        .insert(*existing_id, *last_id);
+                    existing_iter.next();
+                    continue;
                 }
             }
 
@@ -2105,10 +2104,10 @@ impl MultiBuffer {
             .flatten()
         {
             cursor.seek_forward(&Some(locator), Bias::Left);
-            if let Some(excerpt) = cursor.item() {
-                if excerpt.locator == *locator {
-                    excerpts.push((excerpt.id, excerpt.range.clone()));
-                }
+            if let Some(excerpt) = cursor.item()
+                && excerpt.locator == *locator
+            {
+                excerpts.push((excerpt.id, excerpt.range.clone()));
             }
         }
 
@@ -2132,22 +2131,21 @@ 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 {
-                    let excerpt_start = excerpts.start().1.clone();
-                    let excerpt_end =
-                        ExcerptDimension(excerpt_start.0 + excerpt.text_summary.lines);
+            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);
 
-                    diff_transforms.seek_forward(&excerpt_start, Bias::Left);
-                    let overshoot = excerpt_start.0 - diff_transforms.start().0.0;
-                    let start = diff_transforms.start().1.0 + overshoot;
+                diff_transforms.seek_forward(&excerpt_start, Bias::Left);
+                let overshoot = excerpt_start.0 - diff_transforms.start().0.0;
+                let start = diff_transforms.start().1.0 + overshoot;
 
-                    diff_transforms.seek_forward(&excerpt_end, Bias::Right);
-                    let overshoot = excerpt_end.0 - diff_transforms.start().0.0;
-                    let end = diff_transforms.start().1.0 + overshoot;
+                diff_transforms.seek_forward(&excerpt_end, Bias::Right);
+                let overshoot = excerpt_end.0 - diff_transforms.start().0.0;
+                let end = diff_transforms.start().1.0 + overshoot;
 
-                    result.push(start..end)
-                }
+                result.push(start..end)
             }
         }
         result
@@ -2316,12 +2314,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 {
-                                excerpt_ids.next();
-                                excerpt = next_excerpt;
-                                continue 'remove_excerpts;
-                            }
+                        if let Some(next_excerpt) = cursor.item()
+                            && next_excerpt.locator == *next_locator
+                        {
+                            excerpt_ids.next();
+                            excerpt = next_excerpt;
+                            continue 'remove_excerpts;
                         }
                     }
 
@@ -2494,33 +2492,33 @@ impl MultiBuffer {
                 .excerpts
                 .cursor::<Dimensions<Option<&Locator>, ExcerptOffset>>(&());
             cursor.seek_forward(&Some(locator), Bias::Left);
-            if let Some(excerpt) = cursor.item() {
-                if 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
-                    {
-                        continue;
-                    }
-                    let excerpt_start = cursor.start().1;
-                    let excerpt_len = ExcerptOffset::new(excerpt.text_summary.len);
-                    let diff_change_start_in_excerpt = ExcerptOffset::new(
-                        diff_change_range
-                            .start
-                            .saturating_sub(excerpt_buffer_range.start),
-                    );
-                    let diff_change_end_in_excerpt = ExcerptOffset::new(
-                        diff_change_range
-                            .end
-                            .saturating_sub(excerpt_buffer_range.start),
-                    );
-                    let edit_start = excerpt_start + diff_change_start_in_excerpt.min(excerpt_len);
-                    let edit_end = excerpt_start + diff_change_end_in_excerpt.min(excerpt_len);
-                    excerpt_edits.push(Edit {
-                        old: edit_start..edit_end,
-                        new: edit_start..edit_end,
-                    });
+            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
+                {
+                    continue;
                 }
+                let excerpt_start = cursor.start().1;
+                let excerpt_len = ExcerptOffset::new(excerpt.text_summary.len);
+                let diff_change_start_in_excerpt = ExcerptOffset::new(
+                    diff_change_range
+                        .start
+                        .saturating_sub(excerpt_buffer_range.start),
+                );
+                let diff_change_end_in_excerpt = ExcerptOffset::new(
+                    diff_change_range
+                        .end
+                        .saturating_sub(excerpt_buffer_range.start),
+                );
+                let edit_start = excerpt_start + diff_change_start_in_excerpt.min(excerpt_len);
+                let edit_end = excerpt_start + diff_change_end_in_excerpt.min(excerpt_len);
+                excerpt_edits.push(Edit {
+                    old: edit_start..edit_end,
+                    new: edit_start..edit_end,
+                });
             }
         }
 
@@ -3155,13 +3153,12 @@ 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
-                        && old_diff_transforms.start().0 < edit.old.start
-                    {
-                        self.push_diff_transform(&mut new_diff_transforms, transform.clone());
-                        old_diff_transforms.next();
-                    }
+                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();
                 }
             }
 
@@ -3431,18 +3428,17 @@ 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,
-            ) {
-                let mut cursor = subtree.cursor::<()>(&());
-                cursor.next();
-                cursor.next();
-                new_transforms.append(cursor.suffix(), &());
-                return;
-            }
+            )
+        {
+            let mut cursor = subtree.cursor::<()>(&());
+            cursor.next();
+            cursor.next();
+            new_transforms.append(cursor.suffix(), &());
+            return;
         }
         new_transforms.append(subtree, &());
     }
@@ -3456,14 +3452,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;
-            }
+            )
+        {
+            return;
         }
         new_transforms.push(transform, &());
     }
@@ -3518,11 +3513,10 @@ impl MultiBuffer {
                     summary,
                     inserted_hunk_info: inserted_hunk_anchor,
                 } = last_transform
+                    && *inserted_hunk_anchor == new_inserted_hunk_info
                 {
-                    if *inserted_hunk_anchor == new_inserted_hunk_info {
-                        *summary += summary_to_add;
-                        did_extend = true;
-                    }
+                    *summary += summary_to_add;
+                    did_extend = true;
                 }
             },
             &(),
@@ -4037,10 +4031,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(&()) {
-                cursor.prev()
-            }
+        if let Some(region) = cursor.region().filter(|region| !region.is_main_buffer)
+            && region.range.start > D::zero(&())
+        {
+            cursor.prev()
         }
 
         iter::from_fn(move || {
@@ -4070,10 +4064,10 @@ impl MultiBufferSnapshot {
                         buffer_start = cursor.main_buffer_position()?;
                     };
                     let mut buffer_end = excerpt.range.context.end.summary::<D>(&excerpt.buffer);
-                    if let Some((end_excerpt_id, end_buffer_offset)) = range_end {
-                        if excerpt.id == end_excerpt_id {
-                            buffer_end = buffer_end.min(end_buffer_offset);
-                        }
+                    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) =
@@ -4144,10 +4138,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 {
-                            return None;
-                        }
+                    if let Some((end_excerpt_id, _)) = range_end
+                        && excerpt.id == end_excerpt_id
+                    {
+                        return None;
                     }
                     cursor.next_excerpt();
                 }
@@ -4622,20 +4616,20 @@ 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::<String>();
 
-        if self.language_settings(cx).extend_comment_on_newline {
-            if 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
-                        .chars_at(Point::new(row.0, indent.len() as u32))
-                        .take(delimiter.chars().count())
-                        .collect::<String>()
-                        .as_str()
-                        == **delimiter
-                    {
-                        indent.push_str(delimiter);
-                        break;
-                    }
+        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
+                    .chars_at(Point::new(row.0, indent.len() as u32))
+                    .take(delimiter.chars().count())
+                    .collect::<String>()
+                    .as_str()
+                    == **delimiter
+                {
+                    indent.push_str(delimiter);
+                    break;
                 }
             }
         }
@@ -4893,25 +4887,22 @@ 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())
+                        && 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
                         {
-                            if 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
-                                {
-                                    let position_in_hunk = base_text
-                                        .text_summary_for_range::<D, _>(
-                                            base_text_byte_range.start..base_text_offset,
-                                        );
-                                    position.add_assign(&position_in_hunk);
-                                } else if at_transform_end {
-                                    diff_transforms.next();
-                                    continue;
-                                }
-                            }
+                            let position_in_hunk = base_text.text_summary_for_range::<D, _>(
+                                base_text_byte_range.start..base_text_offset,
+                            );
+                            position.add_assign(&position_in_hunk);
+                        } else if at_transform_end {
+                            diff_transforms.next();
+                            continue;
                         }
                     }
                 }
@@ -4941,20 +4932,19 @@ impl MultiBufferSnapshot {
         }
 
         let mut position = cursor.start().1;
-        if let Some(excerpt) = cursor.item() {
-            if excerpt.id == anchor.excerpt_id {
-                let excerpt_buffer_start = excerpt
-                    .buffer
-                    .offset_for_anchor(&excerpt.range.context.start);
-                let excerpt_buffer_end =
-                    excerpt.buffer.offset_for_anchor(&excerpt.range.context.end);
-                let buffer_position = cmp::min(
-                    excerpt_buffer_end,
-                    excerpt.buffer.offset_for_anchor(&anchor.text_anchor),
-                );
-                if buffer_position > excerpt_buffer_start {
-                    position.value += buffer_position - excerpt_buffer_start;
-                }
+        if let Some(excerpt) = cursor.item()
+            && excerpt.id == anchor.excerpt_id
+        {
+            let excerpt_buffer_start = excerpt
+                .buffer
+                .offset_for_anchor(&excerpt.range.context.start);
+            let excerpt_buffer_end = excerpt.buffer.offset_for_anchor(&excerpt.range.context.end);
+            let buffer_position = cmp::min(
+                excerpt_buffer_end,
+                excerpt.buffer.offset_for_anchor(&anchor.text_anchor),
+            );
+            if buffer_position > excerpt_buffer_start {
+                position.value += buffer_position - excerpt_buffer_start;
             }
         }
         position
@@ -5211,14 +5201,15 @@ impl MultiBufferSnapshot {
             .cursor::<Dimensions<usize, ExcerptOffset>>(&());
         diff_transforms.seek(&offset, Bias::Right);
 
-        if offset == diff_transforms.start().0 && bias == Bias::Left {
-            if let Some(prev_item) = diff_transforms.prev_item() {
-                match prev_item {
-                    DiffTransform::DeletedHunk { .. } => {
-                        diff_transforms.prev();
-                    }
-                    _ => {}
+        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();
                 }
+                _ => {}
             }
         }
         let offset_in_transform = offset - diff_transforms.start().0;
@@ -5296,17 +5287,17 @@ impl MultiBufferSnapshot {
         let locator = self.excerpt_locator_for_id(excerpt_id);
         let mut cursor = self.excerpts.cursor::<Option<&Locator>>(&());
         cursor.seek(locator, Bias::Left);
-        if let Some(excerpt) = cursor.item() {
-            if excerpt.id == excerpt_id {
-                let text_anchor = excerpt.clip_anchor(text_anchor);
-                drop(cursor);
-                return Some(Anchor {
-                    buffer_id: Some(excerpt.buffer_id),
-                    excerpt_id,
-                    text_anchor,
-                    diff_base_anchor: None,
-                });
-            }
+        if let Some(excerpt) = cursor.item()
+            && excerpt.id == excerpt_id
+        {
+            let text_anchor = excerpt.clip_anchor(text_anchor);
+            drop(cursor);
+            return Some(Anchor {
+                buffer_id: Some(excerpt.buffer_id),
+                excerpt_id,
+                text_anchor,
+                diff_base_anchor: None,
+            });
         }
         None
     }
@@ -5860,10 +5851,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() {
-                    prev_settings.take();
-                }
+            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,10 +6183,10 @@ impl MultiBufferSnapshot {
         } else {
             let mut cursor = self.excerpt_ids.cursor::<ExcerptId>(&());
             cursor.seek(&id, Bias::Left);
-            if let Some(entry) = cursor.item() {
-                if entry.id == id {
-                    return &entry.locator;
-                }
+            if let Some(entry) = cursor.item()
+                && entry.id == id
+            {
+                return &entry.locator;
             }
             panic!("invalid excerpt id {id:?}")
         }
@@ -6272,10 +6263,10 @@ impl MultiBufferSnapshot {
     pub fn buffer_range_for_excerpt(&self, excerpt_id: ExcerptId) -> Option<Range<text::Anchor>> {
         let mut cursor = self.excerpts.cursor::<Option<&Locator>>(&());
         let locator = self.excerpt_locator_for_id(excerpt_id);
-        if cursor.seek(&Some(locator), Bias::Left) {
-            if let Some(excerpt) = cursor.item() {
-                return Some(excerpt.range.context.clone());
-            }
+        if cursor.seek(&Some(locator), Bias::Left)
+            && let Some(excerpt) = cursor.item()
+        {
+            return Some(excerpt.range.context.clone());
         }
         None
     }
@@ -6284,10 +6275,10 @@ impl MultiBufferSnapshot {
         let mut cursor = self.excerpts.cursor::<Option<&Locator>>(&());
         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 {
-                return Some(excerpt);
-            }
+        if let Some(excerpt) = cursor.item()
+            && excerpt.id == excerpt_id
+        {
+            return Some(excerpt);
         }
         None
     }
@@ -6446,13 +6437,12 @@ impl MultiBufferSnapshot {
                     inserted_hunk_info: prev_inserted_hunk_info,
                     ..
                 }) = prev_transform
+                    && *inserted_hunk_info == *prev_inserted_hunk_info
                 {
-                    if *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(&())
-                        );
-                    }
+                    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,14 +6542,12 @@ 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();
-                    }
+                {
+                    self.excerpts.next();
                 }
             }
         }
@@ -7855,10 +7843,11 @@ 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() {
-                    self.chunk = chunk.as_bytes();
-                }
+            if !self.range.is_empty()
+                && self.chunk.is_empty()
+                && let Some(chunk) = self.chunks.next()
+            {
+                self.chunk = chunk.as_bytes();
             }
         }
         Ok(len)

crates/multi_buffer/src/multi_buffer_tests.rs πŸ”—

@@ -3592,24 +3592,20 @@ 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] {
-                        let prev_anchor = left_anchors[ix - 1];
-                        assert!(
-                            anchor.cmp(&prev_anchor, snapshot).is_gt(),
-                            "anchor({}, {bias:?}).cmp(&anchor({}, {bias:?}).is_gt()",
-                            offsets[ix],
-                            offsets[ix - 1],
-                        );
-                        assert!(
-                            prev_anchor.cmp(anchor, snapshot).is_lt(),
-                            "anchor({}, {bias:?}).cmp(&anchor({}, {bias:?}).is_lt()",
-                            offsets[ix - 1],
-                            offsets[ix],
-                        );
-                    }
-                }
+            if ix > 0 && *offset == 252 && offset > &offsets[ix - 1] {
+                let prev_anchor = left_anchors[ix - 1];
+                assert!(
+                    anchor.cmp(&prev_anchor, snapshot).is_gt(),
+                    "anchor({}, {bias:?}).cmp(&anchor({}, {bias:?}).is_gt()",
+                    offsets[ix],
+                    offsets[ix - 1],
+                );
+                assert!(
+                    prev_anchor.cmp(anchor, snapshot).is_lt(),
+                    "anchor({}, {bias:?}).cmp(&anchor({}, {bias:?}).is_lt()",
+                    offsets[ix - 1],
+                    offsets[ix],
+                );
             }
         }
     }

crates/notifications/src/notification_store.rs πŸ”—

@@ -138,10 +138,10 @@ impl NotificationStore {
     pub fn notification_for_id(&self, id: u64) -> Option<&NotificationEntry> {
         let mut cursor = self.notifications.cursor::<NotificationId>(&());
         cursor.seek(&NotificationId(id), Bias::Left);
-        if let Some(item) = cursor.item() {
-            if item.id == id {
-                return Some(item);
-            }
+        if let Some(item) = cursor.item()
+            && item.id == id
+        {
+            return Some(item);
         }
         None
     }
@@ -229,25 +229,24 @@ 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(&notification)
-                {
-                    let fetch_message_task = this.channel_store.update(cx, |this, cx| {
-                        this.fetch_channel_messages(vec![message_id], cx)
-                    });
-
-                    cx.spawn(async move |this, cx| {
-                        let messages = fetch_message_task.await?;
-                        this.update(cx, move |this, cx| {
-                            for message in messages {
-                                this.channel_messages.insert(message_id, message);
-                            }
-                            cx.notify();
-                        })
+            {
+                let fetch_message_task = this.channel_store.update(cx, |this, cx| {
+                    this.fetch_channel_messages(vec![message_id], cx)
+                });
+
+                cx.spawn(async move |this, cx| {
+                    let messages = fetch_message_task.await?;
+                    this.update(cx, move |this, cx| {
+                        for message in messages {
+                            this.channel_messages.insert(message_id, message);
+                        }
+                        cx.notify();
                     })
-                    .detach_and_log_err(cx)
-                }
+                })
+                .detach_and_log_err(cx)
             }
             Ok(())
         })?
@@ -390,12 +389,12 @@ impl NotificationStore {
                         });
                     }
                 }
-            } else if let Some(new_notification) = &new_notification {
-                if is_new {
-                    cx.emit(NotificationEvent::NewNotification {
-                        entry: new_notification.clone(),
-                    });
-                }
+            } else if let Some(new_notification) = &new_notification
+                && is_new
+            {
+                cx.emit(NotificationEvent::NewNotification {
+                    entry: new_notification.clone(),
+                });
             }
 
             if let Some(notification) = new_notification {

crates/open_router/src/open_router.rs πŸ”—

@@ -240,10 +240,10 @@ impl MessageContent {
 
 impl From<Vec<MessagePart>> for MessageContent {
     fn from(parts: Vec<MessagePart>) -> Self {
-        if parts.len() == 1 {
-            if let MessagePart::Text { text } = &parts[0] {
-                return Self::Plain(text.clone());
-            }
+        if parts.len() == 1
+            && let MessagePart::Text { text } = &parts[0]
+        {
+            return Self::Plain(text.clone());
         }
         Self::Multipart(parts)
     }

crates/outline_panel/src/outline_panel.rs πŸ”—

@@ -1170,12 +1170,11 @@ impl OutlinePanel {
                     });
                 } else {
                     let mut offset = Point::default();
-                    if let Some(buffer_id) = scroll_to_buffer {
-                        if 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);
-                        }
+                    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| {
@@ -1606,16 +1605,14 @@ 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))
-                    {
-                        folded = true;
-                        buffers_to_fold.extend(
-                            self.buffers_inside_directory(folded_dirs.worktree_id, dir_entry),
-                        );
-                    }
+                {
+                    folded = true;
+                    buffers_to_fold
+                        .extend(self.buffers_inside_directory(folded_dirs.worktree_id, dir_entry));
                 }
                 folded
             }
@@ -2108,11 +2105,11 @@ impl OutlinePanel {
                                 dirs_to_expand.push(current_entry.id);
                             }
 
-                            if traversal.back_to_parent() {
-                                if let Some(parent_entry) = traversal.entry() {
-                                    current_entry = parent_entry.clone();
-                                    continue;
-                                }
+                            if traversal.back_to_parent()
+                                && let Some(parent_entry) = traversal.entry()
+                            {
+                                current_entry = parent_entry.clone();
+                                continue;
                             }
                             break;
                         }
@@ -2475,17 +2472,17 @@ 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 {
-                        search_state
-                            .highlight_search_match_tx
-                            .try_send(HighlightArguments {
-                                multi_buffer_snapshot: multi_buffer_snapshot.clone(),
-                                match_range: match_range.clone(),
-                                search_data: Arc::clone(render_data),
-                            })
-                            .ok();
-                    }
+                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 {
+                            multi_buffer_snapshot: multi_buffer_snapshot.clone(),
+                            match_range: match_range.clone(),
+                            search_data: Arc::clone(render_data),
+                        })
+                        .ok();
                 }
                 return None;
             }
@@ -2833,11 +2830,12 @@ 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() {
-                                                current_entry = parent_entry.to_owned();
-                                                continue;
-                                            }
+                                        if new_entry_added
+                                            && traversal.back_to_parent()
+                                            && let Some(parent_entry) = traversal.entry()
+                                        {
+                                            current_entry = parent_entry.to_owned();
+                                            continue;
                                         }
                                         break;
                                     }
@@ -2878,18 +2876,17 @@ impl OutlinePanel {
                                 entries
                                     .into_iter()
                                     .filter_map(|entry| {
-                                        if auto_fold_dirs {
-                                            if let Some(parent) = entry.path.parent() {
-                                                let children = new_children_count
-                                                    .entry(worktree_id)
-                                                    .or_default()
-                                                    .entry(Arc::from(parent))
-                                                    .or_default();
-                                                if entry.is_dir() {
-                                                    children.dirs += 1;
-                                                } else {
-                                                    children.files += 1;
-                                                }
+                                        if auto_fold_dirs && let Some(parent) = entry.path.parent()
+                                        {
+                                            let children = new_children_count
+                                                .entry(worktree_id)
+                                                .or_default()
+                                                .entry(Arc::from(parent))
+                                                .or_default();
+                                            if entry.is_dir() {
+                                                children.dirs += 1;
+                                            } else {
+                                                children.files += 1;
                                             }
                                         }
 
@@ -3409,30 +3406,29 @@ 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
-                                                .iter()
-                                                .filter(|outline| {
-                                                    (default_depth == 0
-                                                        || outline.depth >= default_depth)
-                                                        && outlines_with_children.contains(&(
-                                                            outline.range.clone(),
-                                                            outline.depth,
-                                                        ))
-                                                })
-                                                .for_each(|outline| {
-                                                    outline_panel.collapsed_entries.insert(
-                                                        CollapsedEntry::Outline(
-                                                            buffer_id,
-                                                            excerpt_id,
-                                                            outline.range.clone(),
-                                                        ),
-                                                    );
-                                                });
-                                        }
+                                    {
+                                        outlines
+                                            .iter()
+                                            .filter(|outline| {
+                                                (default_depth == 0
+                                                    || outline.depth >= default_depth)
+                                                    && outlines_with_children.contains(&(
+                                                        outline.range.clone(),
+                                                        outline.depth,
+                                                    ))
+                                            })
+                                            .for_each(|outline| {
+                                                outline_panel.collapsed_entries.insert(
+                                                    CollapsedEntry::Outline(
+                                                        buffer_id,
+                                                        excerpt_id,
+                                                        outline.range.clone(),
+                                                    ),
+                                                );
+                                            });
                                     }
 
                                     // Even if no outlines to check, we still need to update cached entries
@@ -3611,10 +3607,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,
@@ -3622,9 +3617,8 @@ impl OutlinePanel {
                                     cx,
                                 )
                             })
-                        {
-                            outline_panel.select_entry(new_selected_entry, false, window, cx);
-                        }
+                    {
+                        outline_panel.select_entry(new_selected_entry, false, window, cx);
                     }
 
                     outline_panel.autoscroll(cx);
@@ -3921,19 +3915,19 @@ 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) {
-                                    outline_panel.add_excerpt_entries(
-                                        &mut generation_state,
-                                        buffer_id,
-                                        entry_excerpts,
-                                        depth,
-                                        track_matches,
-                                        is_singleton,
-                                        query.as_deref(),
-                                        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,
+                                    entry_excerpts,
+                                    depth,
+                                    track_matches,
+                                    is_singleton,
+                                    query.as_deref(),
+                                    cx,
+                                );
                             }
                         }
                     }
@@ -4404,15 +4398,15 @@ 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) {
-                        return false;
-                    }
+                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) {
-                        return false;
-                    }
+                if let Some(buffer_id) = match_range.start.buffer_id
+                    && editor.is_buffer_folded(buffer_id, cx)
+                {
+                    return false;
                 }
                 true
             });
@@ -4456,16 +4450,14 @@ impl OutlinePanel {
         cx: &mut Context<Self>,
     ) {
         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.replace_active_editor(active_item, active_editor, window, cx);
-                }
-            }
+            && self.should_replace_active_item(active_item.as_ref())
+        {
+            self.replace_active_editor(active_item, active_editor, window, cx);
         }
 
         cx.notify();
@@ -5067,24 +5059,23 @@ 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)
                                 })
-                            {
-                                if outline_panel.should_replace_active_item(active_item.as_ref()) {
-                                    outline_panel.replace_active_editor(
-                                        active_item,
-                                        active_editor,
-                                        window,
-                                        cx,
-                                    );
-                                } else {
-                                    outline_panel.update_fs_entries(active_editor, None, window, cx)
-                                }
-                                return;
+                        {
+                            if outline_panel.should_replace_active_item(active_item.as_ref()) {
+                                outline_panel.replace_active_editor(
+                                    active_item,
+                                    active_editor,
+                                    window,
+                                    cx,
+                                );
+                            } else {
+                                outline_panel.update_fs_entries(active_editor, None, window, cx)
                             }
+                            return;
                         }
 
                         if !outline_panel.pinned {
@@ -5319,8 +5310,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(
@@ -5344,9 +5335,8 @@ fn subscribe_for_editor_events(
                                 )
                             })
                             .map(PanelEntry::Fs)
-                        {
-                            outline_panel.select_entry(entry_to_select, true, window, cx);
-                        }
+                    {
+                        outline_panel.select_entry(entry_to_select, true, window, cx);
                     }
 
                     outline_panel.update_fs_entries(editor.clone(), debounce, window, cx);

crates/prettier/src/prettier.rs πŸ”—

@@ -185,11 +185,11 @@ impl Prettier {
                     .metadata(&ignore_path)
                     .await
                     .with_context(|| format!("fetching metadata for {ignore_path:?}"))?
+                    && !metadata.is_dir
+                    && !metadata.is_symlink
                 {
-                    if !metadata.is_dir && !metadata.is_symlink {
-                        log::info!("Found prettier ignore at {ignore_path:?}");
-                        return Ok(ControlFlow::Continue(Some(path_to_check)));
-                    }
+                    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()),
@@ -223,13 +223,13 @@ impl Prettier {
                                 })
                             {
                                 let workspace_ignore = path_to_check.join(".prettierignore");
-                                if let Some(metadata) = fs.metadata(&workspace_ignore).await? {
-                                    if !metadata.is_dir {
-                                        log::info!(
-                                            "Found prettier ignore at workspace root {workspace_ignore:?}"
-                                        );
-                                        return Ok(ControlFlow::Continue(Some(path_to_check)));
-                                    }
+                                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,18 +549,16 @@ async fn read_package_json(
         .metadata(&possible_package_json)
         .await
         .with_context(|| format!("fetching metadata for package json {possible_package_json:?}"))?
+        && !package_json_metadata.is_dir
+        && !package_json_metadata.is_symlink
     {
-        if !package_json_metadata.is_dir && !package_json_metadata.is_symlink {
-            let package_json_contents = fs
-                .load(&possible_package_json)
-                .await
-                .with_context(|| format!("reading {possible_package_json:?} file contents"))?;
-            return serde_json::from_str::<HashMap<String, serde_json::Value>>(
-                &package_json_contents,
-            )
+        let package_json_contents = fs
+            .load(&possible_package_json)
+            .await
+            .with_context(|| format!("reading {possible_package_json:?} file contents"))?;
+        return serde_json::from_str::<HashMap<String, serde_json::Value>>(&package_json_contents)
             .map(Some)
             .with_context(|| format!("parsing {possible_package_json:?} file contents"));
-        }
     }
     Ok(None)
 }

crates/project/src/buffer_store.rs πŸ”—

@@ -1094,10 +1094,10 @@ impl BufferStore {
                         .collect::<Vec<_>>()
                 })?;
                 for buffer_task in buffers {
-                    if let Some(buffer) = buffer_task.await.log_err() {
-                        if tx.send(buffer).await.is_err() {
-                            return anyhow::Ok(());
-                        }
+                    if let Some(buffer) = buffer_task.await.log_err()
+                        && tx.send(buffer).await.is_err()
+                    {
+                        return anyhow::Ok(());
                     }
                 }
             }
@@ -1173,11 +1173,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) {
-                buffer.lsp_handle = Some(handle);
-                return;
-            }
+        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,14 +1388,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() {
-                    cx.emit(BufferStoreEvent::SharedBufferClosed(peer_id, buffer_id));
-                    if shared.is_empty() {
-                        this.shared_buffers.remove(&peer_id);
-                    }
-                    return;
+            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",

crates/project/src/debugger/breakpoint_store.rs πŸ”—

@@ -623,12 +623,11 @@ 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()
-                            {
-                                return None;
-                            }
+                        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))

crates/project/src/debugger/memory.rs πŸ”—

@@ -318,14 +318,13 @@ impl Iterator for MemoryIterator {
             return None;
         }
         if let Some((current_page_address, current_memory_chunk)) = self.current_known_page.as_mut()
+            && current_page_address.0 <= self.start
         {
-            if current_page_address.0 <= self.start {
-                if let Some(next_cell) = current_memory_chunk.next() {
-                    self.start += 1;
-                    return Some(next_cell);
-                } else {
-                    self.current_known_page.take();
-                }
+            if let Some(next_cell) = current_memory_chunk.next() {
+                self.start += 1;
+                return Some(next_cell);
+            } else {
+                self.current_known_page.take();
             }
         }
         if !self.fetch_next_page() {

crates/project/src/git_store.rs πŸ”—

@@ -570,23 +570,22 @@ impl GitStore {
         cx: &mut Context<Self>,
     ) -> Task<Result<Entity<BufferDiff>>> {
         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()
                 .and_then(|weak| weak.upgrade())
+        {
+            if let Some(task) =
+                diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
             {
-                if let Some(task) =
-                    diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
-                {
-                    return cx.background_executor().spawn(async move {
-                        task.await;
-                        Ok(unstaged_diff)
-                    });
-                }
-                return Task::ready(Ok(unstaged_diff));
+                return cx.background_executor().spawn(async move {
+                    task.await;
+                    Ok(unstaged_diff)
+                });
             }
+            return Task::ready(Ok(unstaged_diff));
         }
 
         let Some((repo, repo_path)) =
@@ -627,23 +626,22 @@ impl GitStore {
     ) -> Task<Result<Entity<BufferDiff>>> {
         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()
                 .and_then(|weak| weak.upgrade())
+        {
+            if let Some(task) =
+                diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
             {
-                if let Some(task) =
-                    diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
-                {
-                    return cx.background_executor().spawn(async move {
-                        task.await;
-                        Ok(uncommitted_diff)
-                    });
-                }
-                return Task::ready(Ok(uncommitted_diff));
+                return cx.background_executor().spawn(async move {
+                    task.await;
+                    Ok(uncommitted_diff)
+                });
             }
+            return Task::ready(Ok(uncommitted_diff));
         }
 
         let Some((repo, repo_path)) =
@@ -764,22 +762,21 @@ 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()
                 .and_then(|weak| weak.upgrade())
-            {
-                let conflict_set = conflict_set.clone();
-                let buffer_snapshot = buffer.read(cx).text_snapshot();
+        {
+            let conflict_set = conflict_set.clone();
+            let buffer_snapshot = buffer.read(cx).text_snapshot();
 
-                git_state.update(cx, |state, cx| {
-                    let _ = state.reparse_conflict_markers(buffer_snapshot, cx);
-                });
+            git_state.update(cx, |state, cx| {
+                let _ = state.reparse_conflict_markers(buffer_snapshot, cx);
+            });
 
-                return conflict_set;
-            }
+            return conflict_set;
         }
 
         let is_unmerged = self
@@ -1151,29 +1148,26 @@ 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)
+                && buffer_repo == repo
             {
-                if buffer_repo == repo {
-                    diff.update(cx, |diff, cx| {
-                        if let Some(conflict_set) = &diff.conflict_set {
-                            let conflict_status_changed =
-                                conflict_set.update(cx, |conflict_set, cx| {
-                                    let has_conflict = repo_snapshot.has_conflict(&repo_path);
-                                    conflict_set.set_has_conflict(has_conflict, cx)
-                                })?;
-                            if conflict_status_changed {
-                                let buffer_store = self.buffer_store.read(cx);
-                                if let Some(buffer) = buffer_store.get(*buffer_id) {
-                                    let _ = diff.reparse_conflict_markers(
-                                        buffer.read(cx).text_snapshot(),
-                                        cx,
-                                    );
-                                }
+                diff.update(cx, |diff, cx| {
+                    if let Some(conflict_set) = &diff.conflict_set {
+                        let conflict_status_changed =
+                            conflict_set.update(cx, |conflict_set, cx| {
+                                let has_conflict = repo_snapshot.has_conflict(&repo_path);
+                                conflict_set.set_has_conflict(has_conflict, cx)
+                            })?;
+                        if conflict_status_changed {
+                            let buffer_store = self.buffer_store.read(cx);
+                            if let Some(buffer) = buffer_store.get(*buffer_id) {
+                                let _ = diff
+                                    .reparse_conflict_markers(buffer.read(cx).text_snapshot(), cx);
                             }
                         }
-                        anyhow::Ok(())
-                    })
-                    .ok();
-                }
+                    }
+                    anyhow::Ok(())
+                })
+                .ok();
             }
         }
         cx.emit(GitStoreEvent::RepositoryUpdated(
@@ -2231,13 +2225,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) {
-                    let buffer = buffer.read(cx).text_snapshot();
-                    diff_state.update(cx, |diff_state, cx| {
-                        diff_state.handle_base_texts_updated(buffer, request.payload, cx);
-                    })
-                }
+            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,14 +3527,13 @@ 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));
-                        }
+                    {
+                        save_futures.push(buffer_store.save_buffer(buffer, cx));
                     }
                 }
             })
@@ -3600,14 +3593,13 @@ 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));
-                        }
+                    {
+                        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,13 +4450,12 @@ 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;
-                        }
+                    {
+                        continue;
                     }
                     (job.job)(state.clone(), cx).await;
                 } else if let Some(job) = job_rx.next().await {
@@ -4589,10 +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) {
-                                    continue;
-                                }
+                            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 {

crates/project/src/git_store/git_traversal.rs πŸ”—

@@ -182,11 +182,11 @@ impl<'a> Iterator for ChildEntriesGitIter<'a> {
     type Item = GitEntryRef<'a>;
 
     fn next(&mut self) -> Option<Self::Item> {
-        if let Some(item) = self.traversal.entry() {
-            if item.path.starts_with(self.parent_path) {
-                self.traversal.advance_to_sibling();
-                return Some(item);
-            }
+        if let Some(item) = self.traversal.entry()
+            && item.path.starts_with(self.parent_path)
+        {
+            self.traversal.advance_to_sibling();
+            return Some(item);
         }
         None
     }

crates/project/src/lsp_command.rs πŸ”—

@@ -2341,15 +2341,14 @@ 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())
-                    {
-                        // Servers (e.g. JDTLS) prefer unchanged completions, when resolving the items later,
-                        // 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);
-                    }
+                {
+                    // Servers (e.g. JDTLS) prefer unchanged completions, when resolving the items later,
+                    // 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,
@@ -2623,10 +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) {
-                                return None;
-                            }
+                        if let Some(command) = lsp_action.command.as_ref()
+                            && !available_commands.contains(&command.command)
+                        {
+                            return None;
                         }
                         (LspAction::Action(Box::new(lsp_action)), false)
                     }
@@ -2641,10 +2640,9 @@ impl LspCommand for GetCodeActions {
 
                 if let Some((requested_kinds, kind)) =
                     requested_kinds_set.as_ref().zip(lsp_action.action_kind())
+                    && !requested_kinds.contains(&kind)
                 {
-                    if !requested_kinds.contains(&kind) {
-                        return None;
-                    }
+                    return None;
                 }
 
                 Some(CodeAction {

crates/project/src/lsp_store.rs πŸ”—

@@ -701,10 +701,9 @@ impl LocalLspStore {
                     async move {
                         this.update(&mut cx, |this, _| {
                             if let Some(status) = this.language_server_statuses.get_mut(&server_id)
+                                && let lsp::NumberOrString::String(token) = params.token
                             {
-                                if let lsp::NumberOrString::String(token) = params.token {
-                                    status.progress_tokens.insert(token);
-                                }
+                                status.progress_tokens.insert(token);
                             }
                         })?;
 
@@ -1015,10 +1014,10 @@ impl LocalLspStore {
                 }
             }
             LanguageServerState::Starting { startup, .. } => {
-                if let Some(server) = startup.await {
-                    if let Some(shutdown) = server.shutdown() {
-                        shutdown.await;
-                    }
+                if let Some(server) = startup.await
+                    && let Some(shutdown) = server.shutdown()
+                {
+                    shutdown.await;
                 }
             }
         }
@@ -2384,15 +2383,15 @@ 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)) {
-                            return None;
-                        }
+                    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)) {
-                            return None;
-                        }
+                    if let Some(name) = server_node.name()
+                        && !only_register_servers.contains(&LanguageServerSelector::Name(name))
+                    {
+                        return None;
                     }
                 }
 
@@ -2410,11 +2409,11 @@ impl LocalLspStore {
                             cx,
                         );
 
-                        if let Some(state) = self.language_servers.get(&server_id) {
-                            if let Ok(uri) = uri {
-                                state.add_workspace_folder(uri);
-                            };
-                        }
+                        if let Some(state) = self.language_servers.get(&server_id)
+                            && let Ok(uri) = uri
+                        {
+                            state.add_workspace_folder(uri);
+                        };
                         server_id
                     };
 
@@ -3844,13 +3843,13 @@ 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()) {
-                        local.reset_buffer(buffer, old_file, cx);
+                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);
-                        }
+                    if local.registered_buffers.contains_key(&buffer_id) {
+                        local.unregister_old_buffer_from_language_servers(buffer, old_file, cx);
                     }
                 }
 
@@ -4201,14 +4200,12 @@ 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,
-                                                    );
-                                                }
+                                            {
+                                                local.unregister_buffer_from_language_servers(
+                                                    &buffer, &file_url, cx,
+                                                );
                                             }
                                         }
                                     }
@@ -4306,20 +4303,13 @@ 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) =
-                    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() {
-                        local_store.unregister_buffer_from_language_servers(
-                            buffer_entity,
-                            &file_url,
-                            cx,
-                        );
-                    }
-                }
-            }
+        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))
+            && 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| {
@@ -4336,33 +4326,28 @@ 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) {
-                    local.register_buffer_with_language_servers(
-                        buffer_entity,
-                        HashSet::default(),
-                        cx,
-                    );
-                }
+            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)
-            {
-                let prettier_store = self.as_local().map(|s| s.prettier_store.clone());
-                if let Some(prettier_store) = prettier_store {
-                    prettier_store.update(cx, |prettier_store, cx| {
-                        prettier_store.install_default_prettier(
-                            worktree_id,
-                            prettier_plugins.iter().map(|s| Arc::from(s.as_str())),
-                            cx,
-                        )
-                    })
-                }
+        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 {
+                prettier_store.update(cx, |prettier_store, cx| {
+                    prettier_store.install_default_prettier(
+                        worktree_id,
+                        prettier_plugins.iter().map(|s| Arc::from(s.as_str())),
+                        cx,
+                    )
+                })
             }
         }
 
@@ -4381,26 +4366,25 @@ 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()) {
-                let mut summaries =
-                    diangostic_summaries
+        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()
+                .flat_map(|(path, summaries)| {
+                    summaries
                         .into_iter()
-                        .flat_map(|(path, summaries)| {
-                            summaries
-                                .into_iter()
-                                .map(|(server_id, summary)| summary.to_proto(*server_id, path))
-                        });
-                if let Some(summary) = summaries.next() {
-                    client
-                        .send(proto::UpdateDiagnosticSummary {
-                            project_id: downstream_project_id,
-                            worktree_id: worktree.id().to_proto(),
-                            summary: Some(summary),
-                            more_summaries: summaries.collect(),
-                        })
-                        .log_err();
-                }
+                        .map(|(server_id, summary)| summary.to_proto(*server_id, path))
+                });
+            if let Some(summary) = summaries.next() {
+                client
+                    .send(proto::UpdateDiagnosticSummary {
+                        project_id: downstream_project_id,
+                        worktree_id: worktree.id().to_proto(),
+                        summary: Some(summary),
+                        more_summaries: summaries.collect(),
+                    })
+                    .log_err();
             }
         }
     }
@@ -4730,11 +4714,11 @@ impl LspStore {
                                 &language.name(),
                                 cx,
                             );
-                            if let Some(state) = local.language_servers.get(&server_id) {
-                                if let Ok(uri) = uri {
-                                    state.add_workspace_folder(uri);
-                                };
-                            }
+                            if let Some(state) = local.language_servers.get(&server_id)
+                                && let Ok(uri) = uri
+                            {
+                                state.add_workspace_folder(uri);
+                            };
                             server_id
                         });
 
@@ -4805,8 +4789,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 +4801,6 @@ impl LspStore {
                         )
                         .await;
                     }
-                }
 
                 if let Some(command) = action.lsp_action.command() {
                     let server_capabilities = lang_server.capabilities();
@@ -5736,28 +5719,28 @@ 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) {
-                let has_different_servers = self.as_local().is_some_and(|local| {
-                    local
-                        .buffers_opened_in_servers
-                        .get(&buffer_id)
-                        .cloned()
-                        .unwrap_or_default()
-                        != cached_data.lens.keys().copied().collect()
-                });
-                if !has_different_servers {
-                    return Task::ready(Ok(cached_data.lens.values().flatten().cloned().collect()))
-                        .shared();
-                }
+        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
+                    .get(&buffer_id)
+                    .cloned()
+                    .unwrap_or_default()
+                    != cached_data.lens.keys().copied().collect()
+            });
+            if !has_different_servers {
+                return Task::ready(Ok(cached_data.lens.values().flatten().cloned().collect()))
+                    .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) {
-                return running_update.clone();
-            }
+        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();
@@ -6372,11 +6355,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() {
-                completion.new_text = response.new_text;
-                completion.replace_range = old_replace_start..old_replace_end;
-            }
+        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,33 +6734,33 @@ 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) {
-                        let has_different_servers = self.as_local().is_some_and(|local| {
-                            local
-                                .buffers_opened_in_servers
-                                .get(&buffer_id)
-                                .cloned()
-                                .unwrap_or_default()
-                                != cached_data.colors.keys().copied().collect()
-                        });
-                        if !has_different_servers {
-                            if Some(cached_data.cache_version) == known_cache_version {
-                                return None;
-                            } else {
-                                return Some(
-                                    Task::ready(Ok(DocumentColors {
-                                        colors: cached_data
-                                            .colors
-                                            .values()
-                                            .flatten()
-                                            .cloned()
-                                            .collect(),
-                                        cache_version: Some(cached_data.cache_version),
-                                    }))
-                                    .shared(),
-                                );
-                            }
+                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
+                            .get(&buffer_id)
+                            .cloned()
+                            .unwrap_or_default()
+                            != cached_data.colors.keys().copied().collect()
+                    });
+                    if !has_different_servers {
+                        if Some(cached_data.cache_version) == known_cache_version {
+                            return None;
+                        } else {
+                            return Some(
+                                Task::ready(Ok(DocumentColors {
+                                    colors: cached_data
+                                        .colors
+                                        .values()
+                                        .flatten()
+                                        .cloned()
+                                        .collect(),
+                                    cache_version: Some(cached_data.cache_version),
+                                }))
+                                .shared(),
+                            );
                         }
                     }
                 }
@@ -6785,10 +6768,10 @@ 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) {
-                return Some(running_update.clone());
-            }
+        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
@@ -8785,12 +8768,11 @@ impl LspStore {
                 if summary.is_empty() {
                     if let Some(worktree_summaries) =
                         lsp_store.diagnostic_summaries.get_mut(&worktree_id)
+                        && let Some(summaries) = worktree_summaries.get_mut(&path)
                     {
-                        if let Some(summaries) = worktree_summaries.get_mut(&path) {
-                            summaries.remove(&server_id);
-                            if summaries.is_empty() {
-                                worktree_summaries.remove(&path);
-                            }
+                        summaries.remove(&server_id);
+                        if summaries.is_empty() {
+                            worktree_summaries.remove(&path);
                         }
                     }
                 } else {
@@ -9491,10 +9473,10 @@ impl LspStore {
         cx: &mut Context<Self>,
     ) {
         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 {
-                    cx.emit(LspStoreEvent::RefreshInlayHints);
-                }
+            if let Some(work) = status.pending_work.remove(&token)
+                && !work.is_disk_based_diagnostics_progress
+            {
+                cx.emit(LspStoreEvent::RefreshInlayHints);
             }
             cx.notify();
         }
@@ -10288,10 +10270,10 @@ impl LspStore {
             None => None,
         };
 
-        if let Some(server) = server {
-            if let Some(shutdown) = server.shutdown() {
-                shutdown.await;
-            }
+        if let Some(server) = server
+            && let Some(shutdown) = server.shutdown()
+        {
+            shutdown.await;
         }
     }
 
@@ -10565,18 +10547,18 @@ 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) {
-                        language_server_names_to_stop.retain(|name| {
-                            let old_ids_count = language_servers_to_stop.len();
-                            let all_language_servers_with_this_name = local
-                                .language_server_ids
-                                .iter()
-                                .filter_map(|(seed, state)| seed.name.eq(name).then(|| state.id));
-                            language_servers_to_stop.extend(all_language_servers_with_this_name);
-                            old_ids_count == language_servers_to_stop.len()
-                        });
-                    }
+                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
+                            .language_server_ids
+                            .iter()
+                            .filter_map(|(seed, state)| seed.name.eq(name).then(|| state.id));
+                        language_servers_to_stop.extend(all_language_servers_with_this_name);
+                        old_ids_count == language_servers_to_stop.len()
+                    });
                 }
             });
         }
@@ -11081,10 +11063,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 {
-                            continue;
-                        }
+                    if let Some(token_to_cancel) = token_to_cancel.as_ref()
+                        && token != token_to_cancel
+                    {
+                        continue;
                     }
                     if progress.is_cancellable {
                         server
@@ -11191,38 +11173,36 @@ 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))
-                {
-                    let params = lsp::DidChangeWatchedFilesParams {
-                        changes: changes
-                            .iter()
-                            .filter_map(|(path, _, change)| {
-                                if !watched_paths.is_match(path) {
-                                    return None;
-                                }
-                                let typ = match change {
-                                    PathChange::Loaded => return None,
-                                    PathChange::Added => lsp::FileChangeType::CREATED,
-                                    PathChange::Removed => lsp::FileChangeType::DELETED,
-                                    PathChange::Updated => lsp::FileChangeType::CHANGED,
-                                    PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
-                                };
-                                Some(lsp::FileEvent {
-                                    uri: lsp::Url::from_file_path(abs_path.join(path)).unwrap(),
-                                    typ,
-                                })
+            {
+                let params = lsp::DidChangeWatchedFilesParams {
+                    changes: changes
+                        .iter()
+                        .filter_map(|(path, _, change)| {
+                            if !watched_paths.is_match(path) {
+                                return None;
+                            }
+                            let typ = match change {
+                                PathChange::Loaded => return None,
+                                PathChange::Added => lsp::FileChangeType::CREATED,
+                                PathChange::Removed => lsp::FileChangeType::DELETED,
+                                PathChange::Updated => lsp::FileChangeType::CHANGED,
+                                PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
+                            };
+                            Some(lsp::FileEvent {
+                                uri: lsp::Url::from_file_path(abs_path.join(path)).unwrap(),
+                                typ,
                             })
-                            .collect(),
-                    };
-                    if !params.changes.is_empty() {
-                        server
-                            .notify::<lsp::notification::DidChangeWatchedFiles>(&params)
-                            .ok();
-                    }
+                        })
+                        .collect(),
+                };
+                if !params.changes.is_empty() {
+                    server
+                        .notify::<lsp::notification::DidChangeWatchedFiles>(&params)
+                        .ok();
                 }
             }
         }

crates/project/src/manifest_tree/path_trie.rs πŸ”—

@@ -84,11 +84,11 @@ impl<Label: Ord + Clone> RootPathTrie<Label> {
     ) {
         let mut current = self;
         for key in path.0.iter() {
-            if !current.labels.is_empty() {
-                if (callback)(&current.worktree_relative_path, &current.labels).is_break() {
-                    return;
-                };
-            }
+            if !current.labels.is_empty()
+                && (callback)(&current.worktree_relative_path, &current.labels).is_break()
+            {
+                return;
+            };
             current = match current.children.get(key) {
                 Some(child) => child,
                 None => return,

crates/project/src/prettier_store.rs πŸ”—

@@ -590,8 +590,8 @@ impl PrettierStore {
                             new_plugins.clear();
                         }
                         let mut needs_install = should_write_prettier_server_file(fs.as_ref()).await;
-                        if let Some(previous_installation_task) = previous_installation_task {
-                            if let Err(e) = previous_installation_task.await {
+                        if let Some(previous_installation_task) = previous_installation_task
+                            && let Err(e) = previous_installation_task.await {
                                 log::error!("Failed to install default prettier: {e:#}");
                                 prettier_store.update(cx, |prettier_store, _| {
                                     if let PrettierInstallation::NotInstalled { attempts, not_installed_plugins, .. } = &mut prettier_store.default_prettier.prettier {
@@ -601,8 +601,7 @@ impl PrettierStore {
                                         needs_install = true;
                                     };
                                 })?;
-                            }
-                        };
+                            };
                         if installation_attempt > prettier::FAIL_THRESHOLD {
                             prettier_store.update(cx, |prettier_store, _| {
                                 if let PrettierInstallation::NotInstalled { installation_task, .. } = &mut prettier_store.default_prettier.prettier {
@@ -679,13 +678,13 @@ impl PrettierStore {
     ) {
         let mut prettier_plugins_by_worktree = HashMap::default();
         for (worktree, language_settings) in language_formatters_to_check {
-            if language_settings.prettier.allowed {
-                if let Some(plugins) = prettier_plugins_for_language(&language_settings) {
-                    prettier_plugins_by_worktree
-                        .entry(worktree)
-                        .or_insert_with(HashSet::default)
-                        .extend(plugins.iter().cloned());
-                }
+            if language_settings.prettier.allowed
+                && let Some(plugins) = prettier_plugins_for_language(&language_settings)
+            {
+                prettier_plugins_by_worktree
+                    .entry(worktree)
+                    .or_insert_with(HashSet::default)
+                    .extend(plugins.iter().cloned());
             }
         }
         for (worktree, prettier_plugins) in prettier_plugins_by_worktree {

crates/project/src/project.rs πŸ”—

@@ -489,67 +489,63 @@ impl CompletionSource {
             ..
         } = self
         {
-            if apply_defaults {
-                if let Some(lsp_defaults) = lsp_defaults {
-                    let mut completion_with_defaults = *lsp_completion.clone();
-                    let default_commit_characters = lsp_defaults.commit_characters.as_ref();
-                    let default_edit_range = lsp_defaults.edit_range.as_ref();
-                    let default_insert_text_format = lsp_defaults.insert_text_format.as_ref();
-                    let default_insert_text_mode = lsp_defaults.insert_text_mode.as_ref();
-
-                    if default_commit_characters.is_some()
-                        || default_edit_range.is_some()
-                        || default_insert_text_format.is_some()
-                        || default_insert_text_mode.is_some()
+            if apply_defaults && let Some(lsp_defaults) = lsp_defaults {
+                let mut completion_with_defaults = *lsp_completion.clone();
+                let default_commit_characters = lsp_defaults.commit_characters.as_ref();
+                let default_edit_range = lsp_defaults.edit_range.as_ref();
+                let default_insert_text_format = lsp_defaults.insert_text_format.as_ref();
+                let default_insert_text_mode = lsp_defaults.insert_text_mode.as_ref();
+
+                if default_commit_characters.is_some()
+                    || default_edit_range.is_some()
+                    || default_insert_text_format.is_some()
+                    || default_insert_text_mode.is_some()
+                {
+                    if completion_with_defaults.commit_characters.is_none()
+                        && default_commit_characters.is_some()
                     {
-                        if completion_with_defaults.commit_characters.is_none()
-                            && default_commit_characters.is_some()
-                        {
-                            completion_with_defaults.commit_characters =
-                                default_commit_characters.cloned()
-                        }
-                        if completion_with_defaults.text_edit.is_none() {
-                            match default_edit_range {
-                                Some(lsp::CompletionListItemDefaultsEditRange::Range(range)) => {
-                                    completion_with_defaults.text_edit =
-                                        Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit {
-                                            range: *range,
+                        completion_with_defaults.commit_characters =
+                            default_commit_characters.cloned()
+                    }
+                    if completion_with_defaults.text_edit.is_none() {
+                        match default_edit_range {
+                            Some(lsp::CompletionListItemDefaultsEditRange::Range(range)) => {
+                                completion_with_defaults.text_edit =
+                                    Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit {
+                                        range: *range,
+                                        new_text: completion_with_defaults.label.clone(),
+                                    }))
+                            }
+                            Some(lsp::CompletionListItemDefaultsEditRange::InsertAndReplace {
+                                insert,
+                                replace,
+                            }) => {
+                                completion_with_defaults.text_edit =
+                                    Some(lsp::CompletionTextEdit::InsertAndReplace(
+                                        lsp::InsertReplaceEdit {
                                             new_text: completion_with_defaults.label.clone(),
-                                        }))
-                                }
-                                Some(
-                                    lsp::CompletionListItemDefaultsEditRange::InsertAndReplace {
-                                        insert,
-                                        replace,
-                                    },
-                                ) => {
-                                    completion_with_defaults.text_edit =
-                                        Some(lsp::CompletionTextEdit::InsertAndReplace(
-                                            lsp::InsertReplaceEdit {
-                                                new_text: completion_with_defaults.label.clone(),
-                                                insert: *insert,
-                                                replace: *replace,
-                                            },
-                                        ))
-                                }
-                                None => {}
+                                            insert: *insert,
+                                            replace: *replace,
+                                        },
+                                    ))
                             }
-                        }
-                        if completion_with_defaults.insert_text_format.is_none()
-                            && default_insert_text_format.is_some()
-                        {
-                            completion_with_defaults.insert_text_format =
-                                default_insert_text_format.cloned()
-                        }
-                        if completion_with_defaults.insert_text_mode.is_none()
-                            && default_insert_text_mode.is_some()
-                        {
-                            completion_with_defaults.insert_text_mode =
-                                default_insert_text_mode.cloned()
+                            None => {}
                         }
                     }
-                    return Some(Cow::Owned(completion_with_defaults));
+                    if completion_with_defaults.insert_text_format.is_none()
+                        && default_insert_text_format.is_some()
+                    {
+                        completion_with_defaults.insert_text_format =
+                            default_insert_text_format.cloned()
+                    }
+                    if completion_with_defaults.insert_text_mode.is_none()
+                        && default_insert_text_mode.is_some()
+                    {
+                        completion_with_defaults.insert_text_mode =
+                            default_insert_text_mode.cloned()
+                    }
                 }
+                return Some(Cow::Owned(completion_with_defaults));
             }
             Some(Cow::Borrowed(lsp_completion))
         } else {
@@ -2755,11 +2751,12 @@ impl Project {
                         operations,
                     }))
                 })?;
-                if let Some(request) = request {
-                    if request.await.is_err() && !is_local {
-                        *needs_resync_with_host = true;
-                        break;
-                    }
+                if let Some(request) = request
+                    && request.await.is_err()
+                    && !is_local
+                {
+                    *needs_resync_with_host = true;
+                    break;
                 }
             }
             Ok(())
@@ -3939,10 +3936,10 @@ impl Project {
                     if let Some(entry) = b
                         .entry_id(cx)
                         .and_then(|entry_id| worktree_store.entry_for_id(entry_id, cx))
+                        && entry.is_ignored
+                        && !search_query.include_ignored()
                     {
-                        if entry.is_ignored && !search_query.include_ignored() {
-                            return false;
-                        }
+                        return false;
                     }
                 }
                 true
@@ -4151,11 +4148,11 @@ impl Project {
     ) -> Task<Option<ResolvedPath>> {
         let mut candidates = vec![path.clone()];
 
-        if let Some(file) = buffer.read(cx).file() {
-            if let Some(dir) = file.path().parent() {
-                let joined = dir.to_path_buf().join(path);
-                candidates.push(joined);
-            }
+        if let Some(file) = buffer.read(cx).file()
+            && let Some(dir) = file.path().parent()
+        {
+            let joined = dir.to_path_buf().join(path);
+            candidates.push(joined);
         }
 
         let buffer_worktree_id = buffer.read(cx).file().map(|file| file.worktree_id(cx));
@@ -4168,16 +4165,14 @@ impl Project {
             .collect();
 
         cx.spawn(async move |_, cx| {
-            if let Some(buffer_worktree_id) = buffer_worktree_id {
-                if let Some((worktree, _)) = worktrees_with_ids
+            if let Some(buffer_worktree_id) = buffer_worktree_id
+                && let Some((worktree, _)) = worktrees_with_ids
                     .iter()
                     .find(|(_, id)| *id == buffer_worktree_id)
-                {
-                    for candidate in candidates.iter() {
-                        if let Some(path) = Self::resolve_path_in_worktree(worktree, candidate, cx)
-                        {
-                            return Some(path);
-                        }
+            {
+                for candidate in candidates.iter() {
+                    if let Some(path) = Self::resolve_path_in_worktree(worktree, candidate, cx) {
+                        return Some(path);
                     }
                 }
             }

crates/project/src/search.rs πŸ”—

@@ -155,16 +155,16 @@ impl SearchQuery {
         let initial_query = Arc::from(query.as_str());
         if whole_word {
             let mut word_query = String::new();
-            if let Some(first) = query.get(0..1) {
-                if WORD_MATCH_TEST.is_match(first).is_ok_and(|x| !x) {
-                    word_query.push_str("\\b");
-                }
+            if let Some(first) = query.get(0..1)
+                && WORD_MATCH_TEST.is_match(first).is_ok_and(|x| !x)
+            {
+                word_query.push_str("\\b");
             }
             word_query.push_str(&query);
-            if let Some(last) = query.get(query.len() - 1..) {
-                if WORD_MATCH_TEST.is_match(last).is_ok_and(|x| !x) {
-                    word_query.push_str("\\b");
-                }
+            if let Some(last) = query.get(query.len() - 1..)
+                && WORD_MATCH_TEST.is_match(last).is_ok_and(|x| !x)
+            {
+                word_query.push_str("\\b");
             }
             query = word_query
         }

crates/project/src/search_history.rs πŸ”—

@@ -45,20 +45,19 @@ impl SearchHistory {
     }
 
     pub fn add(&mut self, cursor: &mut SearchHistoryCursor, search_string: String) {
-        if self.insertion_behavior == QueryInsertionBehavior::ReplacePreviousIfContains {
-            if let Some(previously_searched) = self.history.back_mut() {
-                if search_string.contains(previously_searched.as_str()) {
-                    *previously_searched = search_string;
-                    cursor.selection = Some(self.history.len() - 1);
-                    return;
-                }
-            }
+        if self.insertion_behavior == QueryInsertionBehavior::ReplacePreviousIfContains
+            && let Some(previously_searched) = self.history.back_mut()
+            && search_string.contains(previously_searched.as_str())
+        {
+            *previously_searched = search_string;
+            cursor.selection = Some(self.history.len() - 1);
+            return;
         }
 
-        if let Some(max_history_len) = self.max_history_len {
-            if self.history.len() >= max_history_len {
-                self.history.pop_front();
-            }
+        if let Some(max_history_len) = self.max_history_len
+            && self.history.len() >= max_history_len
+        {
+            self.history.pop_front();
         }
         self.history.push_back(search_string);
 

crates/project/src/terminals.rs πŸ”—

@@ -119,13 +119,13 @@ impl Project {
         };
 
         let mut settings_location = None;
-        if let Some(path) = path.as_ref() {
-            if let Some((worktree, _)) = self.find_worktree(path, cx) {
-                settings_location = Some(SettingsLocation {
-                    worktree_id: worktree.read(cx).id(),
-                    path,
-                });
-            }
+        if let Some(path) = path.as_ref()
+            && let Some((worktree, _)) = self.find_worktree(path, cx)
+        {
+            settings_location = Some(SettingsLocation {
+                worktree_id: worktree.read(cx).id(),
+                path,
+            });
         }
         let venv = TerminalSettings::get(settings_location, cx)
             .detect_venv
@@ -151,13 +151,13 @@ impl Project {
         cx: &'a App,
     ) -> &'a TerminalSettings {
         let mut settings_location = None;
-        if let Some(path) = path.as_ref() {
-            if let Some((worktree, _)) = self.find_worktree(path, cx) {
-                settings_location = Some(SettingsLocation {
-                    worktree_id: worktree.read(cx).id(),
-                    path,
-                });
-            }
+        if let Some(path) = path.as_ref()
+            && let Some((worktree, _)) = self.find_worktree(path, cx)
+        {
+            settings_location = Some(SettingsLocation {
+                worktree_id: worktree.read(cx).id(),
+                path,
+            });
         }
         TerminalSettings::get(settings_location, cx)
     }
@@ -239,13 +239,13 @@ impl Project {
         let is_ssh_terminal = ssh_details.is_some();
 
         let mut settings_location = None;
-        if let Some(path) = path.as_ref() {
-            if let Some((worktree, _)) = this.find_worktree(path, cx) {
-                settings_location = Some(SettingsLocation {
-                    worktree_id: worktree.read(cx).id(),
-                    path,
-                });
-            }
+        if let Some(path) = path.as_ref()
+            && let Some((worktree, _)) = this.find_worktree(path, cx)
+        {
+            settings_location = Some(SettingsLocation {
+                worktree_id: worktree.read(cx).id(),
+                path,
+            });
         }
         let settings = TerminalSettings::get(settings_location, cx).clone();
 
@@ -665,11 +665,11 @@ pub fn wrap_for_ssh(
             env_changes.push_str(&format!("{}={} ", k, v));
         }
     }
-    if let Some(venv_directory) = venv_directory {
-        if let Ok(str) = shlex::try_quote(venv_directory.to_string_lossy().as_ref()) {
-            let path = RemotePathBuf::new(PathBuf::from(str.to_string()), path_style).to_string();
-            env_changes.push_str(&format!("PATH={}:$PATH ", path));
-        }
+    if let Some(venv_directory) = venv_directory
+        && let Ok(str) = shlex::try_quote(venv_directory.to_string_lossy().as_ref())
+    {
+        let path = RemotePathBuf::new(PathBuf::from(str.to_string()), path_style).to_string();
+        env_changes.push_str(&format!("PATH={}:$PATH ", path));
     }
 
     let commands = if let Some(path) = path {

crates/project_panel/src/project_panel.rs πŸ”—

@@ -652,8 +652,8 @@ impl ProjectPanel {
                     focus_opened_item,
                     allow_preview,
                 } => {
-                    if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
-                        if let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
+                    if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx)
+                        && let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
                             let file_path = entry.path.clone();
                             let worktree_id = worktree.read(cx).id();
                             let entry_id = entry.id;
@@ -703,11 +703,10 @@ impl ProjectPanel {
                                 }
                             }
                         }
-                    }
                 }
                 &Event::SplitEntry { entry_id } => {
-                    if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
-                        if let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
+                    if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx)
+                        && let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
                             workspace
                                 .split_path(
                                     ProjectPath {
@@ -718,7 +717,6 @@ impl ProjectPanel {
                                 )
                                 .detach_and_log_err(cx);
                         }
-                    }
                 }
 
                 _ => {}
@@ -1002,10 +1000,10 @@ impl ProjectPanel {
         if let Some(parent_path) = entry.path.parent() {
             let snapshot = worktree.snapshot();
             let mut child_entries = snapshot.child_entries(parent_path);
-            if let Some(child) = child_entries.next() {
-                if child_entries.next().is_none() {
-                    return child.kind.is_dir();
-                }
+            if let Some(child) = child_entries.next()
+                && child_entries.next().is_none()
+            {
+                return child.kind.is_dir();
             }
         };
         false
@@ -1016,10 +1014,10 @@ impl ProjectPanel {
             let snapshot = worktree.snapshot();
 
             let mut child_entries = snapshot.child_entries(&entry.path);
-            if let Some(child) = child_entries.next() {
-                if child_entries.next().is_none() {
-                    return child.kind.is_dir();
-                }
+            if let Some(child) = child_entries.next()
+                && child_entries.next().is_none()
+            {
+                return child.kind.is_dir();
             }
         }
         false
@@ -1032,12 +1030,12 @@ impl ProjectPanel {
         cx: &mut Context<Self>,
     ) {
         if let Some((worktree, entry)) = self.selected_entry(cx) {
-            if let Some(folded_ancestors) = self.ancestors.get_mut(&entry.id) {
-                if folded_ancestors.current_ancestor_depth > 0 {
-                    folded_ancestors.current_ancestor_depth -= 1;
-                    cx.notify();
-                    return;
-                }
+            if let Some(folded_ancestors) = self.ancestors.get_mut(&entry.id)
+                && folded_ancestors.current_ancestor_depth > 0
+            {
+                folded_ancestors.current_ancestor_depth -= 1;
+                cx.notify();
+                return;
             }
             if entry.is_dir() {
                 let worktree_id = worktree.id();
@@ -1079,12 +1077,12 @@ impl ProjectPanel {
 
     fn collapse_entry(&mut self, entry: Entry, worktree: Entity<Worktree>, cx: &mut Context<Self>) {
         let worktree = worktree.read(cx);
-        if let Some(folded_ancestors) = self.ancestors.get_mut(&entry.id) {
-            if folded_ancestors.current_ancestor_depth + 1 < folded_ancestors.max_ancestor_depth() {
-                folded_ancestors.current_ancestor_depth += 1;
-                cx.notify();
-                return;
-            }
+        if let Some(folded_ancestors) = self.ancestors.get_mut(&entry.id)
+            && folded_ancestors.current_ancestor_depth + 1 < folded_ancestors.max_ancestor_depth()
+        {
+            folded_ancestors.current_ancestor_depth += 1;
+            cx.notify();
+            return;
         }
         let worktree_id = worktree.id();
         let expanded_dir_ids =
@@ -1137,23 +1135,23 @@ impl ProjectPanel {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx) {
-            if let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id) {
-                self.project.update(cx, |project, cx| {
-                    match expanded_dir_ids.binary_search(&entry_id) {
-                        Ok(ix) => {
-                            expanded_dir_ids.remove(ix);
-                        }
-                        Err(ix) => {
-                            project.expand_entry(worktree_id, entry_id, cx);
-                            expanded_dir_ids.insert(ix, entry_id);
-                        }
+        if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx)
+            && let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id)
+        {
+            self.project.update(cx, |project, cx| {
+                match expanded_dir_ids.binary_search(&entry_id) {
+                    Ok(ix) => {
+                        expanded_dir_ids.remove(ix);
                     }
-                });
-                self.update_visible_entries(Some((worktree_id, entry_id)), cx);
-                window.focus(&self.focus_handle);
-                cx.notify();
-            }
+                    Err(ix) => {
+                        project.expand_entry(worktree_id, entry_id, cx);
+                        expanded_dir_ids.insert(ix, entry_id);
+                    }
+                }
+            });
+            self.update_visible_entries(Some((worktree_id, entry_id)), cx);
+            window.focus(&self.focus_handle);
+            cx.notify();
         }
     }
 
@@ -1163,20 +1161,20 @@ impl ProjectPanel {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx) {
-            if let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id) {
-                match expanded_dir_ids.binary_search(&entry_id) {
-                    Ok(_ix) => {
-                        self.collapse_all_for_entry(worktree_id, entry_id, cx);
-                    }
-                    Err(_ix) => {
-                        self.expand_all_for_entry(worktree_id, entry_id, cx);
-                    }
+        if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx)
+            && let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id)
+        {
+            match expanded_dir_ids.binary_search(&entry_id) {
+                Ok(_ix) => {
+                    self.collapse_all_for_entry(worktree_id, entry_id, cx);
+                }
+                Err(_ix) => {
+                    self.expand_all_for_entry(worktree_id, entry_id, cx);
                 }
-                self.update_visible_entries(Some((worktree_id, entry_id)), cx);
-                window.focus(&self.focus_handle);
-                cx.notify();
             }
+            self.update_visible_entries(Some((worktree_id, entry_id)), cx);
+            window.focus(&self.focus_handle);
+            cx.notify();
         }
     }
 
@@ -1251,20 +1249,20 @@ impl ProjectPanel {
     }
 
     fn select_previous(&mut self, _: &SelectPrevious, window: &mut Window, cx: &mut Context<Self>) {
-        if let Some(edit_state) = &self.edit_state {
-            if edit_state.processing_filename.is_none() {
-                self.filename_editor.update(cx, |editor, cx| {
-                    editor.move_to_beginning_of_line(
-                        &editor::actions::MoveToBeginningOfLine {
-                            stop_at_soft_wraps: false,
-                            stop_at_indent: false,
-                        },
-                        window,
-                        cx,
-                    );
-                });
-                return;
-            }
+        if let Some(edit_state) = &self.edit_state
+            && edit_state.processing_filename.is_none()
+        {
+            self.filename_editor.update(cx, |editor, cx| {
+                editor.move_to_beginning_of_line(
+                    &editor::actions::MoveToBeginningOfLine {
+                        stop_at_soft_wraps: false,
+                        stop_at_indent: false,
+                    },
+                    window,
+                    cx,
+                );
+            });
+            return;
         }
         if let Some(selection) = self.selection {
             let (mut worktree_ix, mut entry_ix, _) =
@@ -1341,39 +1339,37 @@ impl ProjectPanel {
                 .project
                 .read(cx)
                 .worktree_for_id(edit_state.worktree_id, cx)
+                && let Some(entry) = worktree.read(cx).entry_for_id(edit_state.entry_id)
             {
-                if let Some(entry) = worktree.read(cx).entry_for_id(edit_state.entry_id) {
-                    let mut already_exists = false;
-                    if edit_state.is_new_entry() {
-                        let new_path = entry.path.join(filename.trim_start_matches('/'));
-                        if worktree
-                            .read(cx)
-                            .entry_for_path(new_path.as_path())
-                            .is_some()
-                        {
-                            already_exists = true;
-                        }
+                let mut already_exists = false;
+                if edit_state.is_new_entry() {
+                    let new_path = entry.path.join(filename.trim_start_matches('/'));
+                    if worktree
+                        .read(cx)
+                        .entry_for_path(new_path.as_path())
+                        .is_some()
+                    {
+                        already_exists = true;
+                    }
+                } else {
+                    let new_path = if let Some(parent) = entry.path.clone().parent() {
+                        parent.join(&filename)
                     } else {
-                        let new_path = if let Some(parent) = entry.path.clone().parent() {
-                            parent.join(&filename)
-                        } else {
-                            filename.clone().into()
-                        };
-                        if let Some(existing) = worktree.read(cx).entry_for_path(new_path.as_path())
-                        {
-                            if existing.id != entry.id {
-                                already_exists = true;
-                            }
-                        }
+                        filename.clone().into()
                     };
-                    if already_exists {
-                        edit_state.validation_state = ValidationState::Error(format!(
-                            "File or directory '{}' already exists at location. Please choose a different name.",
-                            filename
-                        ));
-                        cx.notify();
-                        return;
+                    if let Some(existing) = worktree.read(cx).entry_for_path(new_path.as_path())
+                        && existing.id != entry.id
+                    {
+                        already_exists = true;
                     }
+                };
+                if already_exists {
+                    edit_state.validation_state = ValidationState::Error(format!(
+                        "File or directory '{}' already exists at location. Please choose a different name.",
+                        filename
+                    ));
+                    cx.notify();
+                    return;
                 }
             }
             let trimmed_filename = filename.trim();
@@ -1477,14 +1473,13 @@ impl ProjectPanel {
                 }
                 Ok(CreatedEntry::Included(new_entry)) => {
                     project_panel.update( cx, |project_panel, cx| {
-                        if let Some(selection) = &mut project_panel.selection {
-                            if selection.entry_id == edited_entry_id {
+                        if let Some(selection) = &mut project_panel.selection
+                            && selection.entry_id == edited_entry_id {
                                 selection.worktree_id = worktree_id;
                                 selection.entry_id = new_entry.id;
                                 project_panel.marked_entries.clear();
                                 project_panel.expand_to_selection(cx);
                             }
-                        }
                         project_panel.update_visible_entries(None, cx);
                         if is_new_entry && !is_dir {
                             project_panel.open_entry(new_entry.id, true, false, cx);
@@ -1617,11 +1612,11 @@ impl ProjectPanel {
                         directory_id = entry.id;
                         break;
                     } else {
-                        if let Some(parent_path) = entry.path.parent() {
-                            if let Some(parent_entry) = worktree.entry_for_path(parent_path) {
-                                entry = parent_entry;
-                                continue;
-                            }
+                        if let Some(parent_path) = entry.path.parent()
+                            && let Some(parent_entry) = worktree.entry_for_path(parent_path)
+                        {
+                            entry = parent_entry;
+                            continue;
                         }
                         return;
                     }
@@ -1675,57 +1670,56 @@ impl ProjectPanel {
             worktree_id,
             entry_id,
         }) = self.selection
+            && let Some(worktree) = self.project.read(cx).worktree_for_id(worktree_id, cx)
         {
-            if let Some(worktree) = self.project.read(cx).worktree_for_id(worktree_id, cx) {
-                let sub_entry_id = self.unflatten_entry_id(entry_id);
-                if let Some(entry) = worktree.read(cx).entry_for_id(sub_entry_id) {
-                    #[cfg(target_os = "windows")]
-                    if Some(entry) == worktree.read(cx).root_entry() {
-                        return;
-                    }
+            let sub_entry_id = self.unflatten_entry_id(entry_id);
+            if let Some(entry) = worktree.read(cx).entry_for_id(sub_entry_id) {
+                #[cfg(target_os = "windows")]
+                if Some(entry) == worktree.read(cx).root_entry() {
+                    return;
+                }
 
-                    if Some(entry) == worktree.read(cx).root_entry() {
-                        let settings = ProjectPanelSettings::get_global(cx);
-                        let visible_worktrees_count =
-                            self.project.read(cx).visible_worktrees(cx).count();
-                        if settings.hide_root && visible_worktrees_count == 1 {
-                            return;
-                        }
+                if Some(entry) == worktree.read(cx).root_entry() {
+                    let settings = ProjectPanelSettings::get_global(cx);
+                    let visible_worktrees_count =
+                        self.project.read(cx).visible_worktrees(cx).count();
+                    if settings.hide_root && visible_worktrees_count == 1 {
+                        return;
                     }
+                }
 
-                    self.edit_state = Some(EditState {
-                        worktree_id,
-                        entry_id: sub_entry_id,
-                        leaf_entry_id: Some(entry_id),
-                        is_dir: entry.is_dir(),
-                        processing_filename: None,
-                        previously_focused: None,
-                        depth: 0,
-                        validation_state: ValidationState::None,
-                    });
-                    let file_name = entry
-                        .path
-                        .file_name()
-                        .map(|s| s.to_string_lossy())
-                        .unwrap_or_default()
-                        .to_string();
-                    let selection = selection.unwrap_or_else(|| {
-                        let file_stem = entry.path.file_stem().map(|s| s.to_string_lossy());
-                        let selection_end =
-                            file_stem.map_or(file_name.len(), |file_stem| file_stem.len());
-                        0..selection_end
-                    });
-                    self.filename_editor.update(cx, |editor, cx| {
-                        editor.set_text(file_name, window, cx);
-                        editor.change_selections(Default::default(), window, cx, |s| {
-                            s.select_ranges([selection])
-                        });
-                        window.focus(&editor.focus_handle(cx));
+                self.edit_state = Some(EditState {
+                    worktree_id,
+                    entry_id: sub_entry_id,
+                    leaf_entry_id: Some(entry_id),
+                    is_dir: entry.is_dir(),
+                    processing_filename: None,
+                    previously_focused: None,
+                    depth: 0,
+                    validation_state: ValidationState::None,
+                });
+                let file_name = entry
+                    .path
+                    .file_name()
+                    .map(|s| s.to_string_lossy())
+                    .unwrap_or_default()
+                    .to_string();
+                let selection = selection.unwrap_or_else(|| {
+                    let file_stem = entry.path.file_stem().map(|s| s.to_string_lossy());
+                    let selection_end =
+                        file_stem.map_or(file_name.len(), |file_stem| file_stem.len());
+                    0..selection_end
+                });
+                self.filename_editor.update(cx, |editor, cx| {
+                    editor.set_text(file_name, window, cx);
+                    editor.change_selections(Default::default(), window, cx, |s| {
+                        s.select_ranges([selection])
                     });
-                    self.update_visible_entries(None, cx);
-                    self.autoscroll(cx);
-                    cx.notify();
-                }
+                    window.focus(&editor.focus_handle(cx));
+                });
+                self.update_visible_entries(None, cx);
+                self.autoscroll(cx);
+                cx.notify();
             }
         }
     }
@@ -1831,10 +1825,10 @@ impl ProjectPanel {
             };
             let next_selection = self.find_next_selection_after_deletion(items_to_delete, cx);
             cx.spawn_in(window, async move |panel, cx| {
-                if let Some(answer) = answer {
-                    if answer.await != Ok(0) {
-                        return anyhow::Ok(());
-                    }
+                if let Some(answer) = answer
+                    && answer.await != Ok(0)
+                {
+                    return anyhow::Ok(());
                 }
                 for (entry_id, _) in file_paths {
                     panel
@@ -1999,19 +1993,19 @@ impl ProjectPanel {
     }
 
     fn select_next(&mut self, _: &SelectNext, window: &mut Window, cx: &mut Context<Self>) {
-        if let Some(edit_state) = &self.edit_state {
-            if edit_state.processing_filename.is_none() {
-                self.filename_editor.update(cx, |editor, cx| {
-                    editor.move_to_end_of_line(
-                        &editor::actions::MoveToEndOfLine {
-                            stop_at_soft_wraps: false,
-                        },
-                        window,
-                        cx,
-                    );
-                });
-                return;
-            }
+        if let Some(edit_state) = &self.edit_state
+            && edit_state.processing_filename.is_none()
+        {
+            self.filename_editor.update(cx, |editor, cx| {
+                editor.move_to_end_of_line(
+                    &editor::actions::MoveToEndOfLine {
+                        stop_at_soft_wraps: false,
+                    },
+                    window,
+                    cx,
+                );
+            });
+            return;
         }
         if let Some(selection) = self.selection {
             let (mut worktree_ix, mut entry_ix, _) =
@@ -2032,20 +2026,19 @@ impl ProjectPanel {
                 entries,
                 ..
             }) = self.visible_entries.get(worktree_ix)
+                && let Some(entry) = entries.get(entry_ix)
             {
-                if let Some(entry) = entries.get(entry_ix) {
-                    let selection = SelectedEntry {
-                        worktree_id: *worktree_id,
-                        entry_id: entry.id,
-                    };
-                    self.selection = Some(selection);
-                    if window.modifiers().shift {
-                        self.marked_entries.push(selection);
-                    }
-
-                    self.autoscroll(cx);
-                    cx.notify();
+                let selection = SelectedEntry {
+                    worktree_id: *worktree_id,
+                    entry_id: entry.id,
+                };
+                self.selection = Some(selection);
+                if window.modifiers().shift {
+                    self.marked_entries.push(selection);
                 }
+
+                self.autoscroll(cx);
+                cx.notify();
             }
         } else {
             self.select_first(&SelectFirst {}, window, cx);
@@ -2274,19 +2267,18 @@ impl ProjectPanel {
             entries,
             ..
         }) = self.visible_entries.first()
+            && let Some(entry) = entries.first()
         {
-            if let Some(entry) = entries.first() {
-                let selection = SelectedEntry {
-                    worktree_id: *worktree_id,
-                    entry_id: entry.id,
-                };
-                self.selection = Some(selection);
-                if window.modifiers().shift {
-                    self.marked_entries.push(selection);
-                }
-                self.autoscroll(cx);
-                cx.notify();
+            let selection = SelectedEntry {
+                worktree_id: *worktree_id,
+                entry_id: entry.id,
+            };
+            self.selection = Some(selection);
+            if window.modifiers().shift {
+                self.marked_entries.push(selection);
             }
+            self.autoscroll(cx);
+            cx.notify();
         }
     }
 
@@ -2947,10 +2939,10 @@ impl ProjectPanel {
             let Some(entry) = worktree.entry_for_path(path) else {
                 continue;
             };
-            if entry.is_dir() {
-                if let Err(idx) = expanded_dir_ids.binary_search(&entry.id) {
-                    expanded_dir_ids.insert(idx, entry.id);
-                }
+            if entry.is_dir()
+                && let Err(idx) = expanded_dir_ids.binary_search(&entry.id)
+            {
+                expanded_dir_ids.insert(idx, entry.id);
             }
         }
 
@@ -3024,15 +3016,16 @@ impl ProjectPanel {
 
             let mut new_entry_parent_id = None;
             let mut new_entry_kind = EntryKind::Dir;
-            if let Some(edit_state) = &self.edit_state {
-                if edit_state.worktree_id == worktree_id && edit_state.is_new_entry() {
-                    new_entry_parent_id = Some(edit_state.entry_id);
-                    new_entry_kind = if edit_state.is_dir {
-                        EntryKind::Dir
-                    } else {
-                        EntryKind::File
-                    };
-                }
+            if let Some(edit_state) = &self.edit_state
+                && edit_state.worktree_id == worktree_id
+                && edit_state.is_new_entry()
+            {
+                new_entry_parent_id = Some(edit_state.entry_id);
+                new_entry_kind = if edit_state.is_dir {
+                    EntryKind::Dir
+                } else {
+                    EntryKind::File
+                };
             }
 
             let mut visible_worktree_entries = Vec::new();
@@ -3054,19 +3047,18 @@ impl ProjectPanel {
                 }
                 if auto_collapse_dirs && entry.kind.is_dir() {
                     auto_folded_ancestors.push(entry.id);
-                    if !self.unfolded_dir_ids.contains(&entry.id) {
-                        if let Some(root_path) = worktree_snapshot.root_entry() {
-                            let mut child_entries = worktree_snapshot.child_entries(&entry.path);
-                            if let Some(child) = child_entries.next() {
-                                if entry.path != root_path.path
-                                    && child_entries.next().is_none()
-                                    && child.kind.is_dir()
-                                {
-                                    entry_iter.advance();
+                    if !self.unfolded_dir_ids.contains(&entry.id)
+                        && let Some(root_path) = worktree_snapshot.root_entry()
+                    {
+                        let mut child_entries = worktree_snapshot.child_entries(&entry.path);
+                        if let Some(child) = child_entries.next()
+                            && entry.path != root_path.path
+                            && child_entries.next().is_none()
+                            && child.kind.is_dir()
+                        {
+                            entry_iter.advance();
 
-                                    continue;
-                                }
-                            }
+                            continue;
                         }
                     }
                     let depth = old_ancestors
@@ -3074,10 +3066,10 @@ impl ProjectPanel {
                         .map(|ancestor| ancestor.current_ancestor_depth)
                         .unwrap_or_default()
                         .min(auto_folded_ancestors.len());
-                    if let Some(edit_state) = &mut self.edit_state {
-                        if edit_state.entry_id == entry.id {
-                            edit_state.depth = depth;
-                        }
+                    if let Some(edit_state) = &mut self.edit_state
+                        && edit_state.entry_id == entry.id
+                    {
+                        edit_state.depth = depth;
                     }
                     let mut ancestors = std::mem::take(&mut auto_folded_ancestors);
                     if ancestors.len() > 1 {
@@ -3314,11 +3306,10 @@ impl ProjectPanel {
                             )
                     })?.await?;
 
-                    if answer == 1 {
-                        if let Some(item_idx) = paths.iter().position(|p| p == original_path) {
+                    if answer == 1
+                        && let Some(item_idx) = paths.iter().position(|p| p == original_path) {
                             paths.remove(item_idx);
                         }
-                    }
                 }
 
                 if paths.is_empty() {
@@ -4309,8 +4300,8 @@ impl ProjectPanel {
                         }
                     } else if kind.is_dir() {
                         project_panel.marked_entries.clear();
-                        if is_sticky {
-                            if let Some((_, _, index)) = project_panel.index_for_entry(entry_id, worktree_id) {
+                        if is_sticky
+                            && let Some((_, _, index)) = project_panel.index_for_entry(entry_id, worktree_id) {
                                 project_panel.scroll_handle.scroll_to_item_with_offset(index, ScrollStrategy::Top, sticky_index.unwrap_or(0));
                                 cx.notify();
                                 // move down by 1px so that clicked item
@@ -4325,7 +4316,6 @@ impl ProjectPanel {
                                 });
                                 return;
                             }
-                        }
                         if event.modifiers().alt {
                             project_panel.toggle_expand_all(entry_id, window, cx);
                         } else {
@@ -4547,15 +4537,14 @@ impl ProjectPanel {
                                                 })
                                             })
                                             .on_click(cx.listener(move |this, _, _, cx| {
-                                                if index != active_index {
-                                                    if let Some(folds) =
+                                                if index != active_index
+                                                    && let Some(folds) =
                                                         this.ancestors.get_mut(&entry_id)
                                                     {
                                                         folds.current_ancestor_depth =
                                                             components_len - 1 - index;
                                                         cx.notify();
                                                     }
-                                                }
                                             }))
                                             .child(
                                                 Label::new(component)
@@ -5034,12 +5023,12 @@ impl ProjectPanel {
         'outer: loop {
             if let Some(parent_path) = current_path.parent() {
                 for ancestor_path in parent_path.ancestors() {
-                    if paths.contains(ancestor_path) {
-                        if let Some(parent_entry) = worktree.entry_for_path(ancestor_path) {
-                            sticky_parents.push(parent_entry.clone());
-                            current_path = parent_entry.path.clone();
-                            continue 'outer;
-                        }
+                    if paths.contains(ancestor_path)
+                        && let Some(parent_entry) = worktree.entry_for_path(ancestor_path)
+                    {
+                        sticky_parents.push(parent_entry.clone());
+                        current_path = parent_entry.path.clone();
+                        continue 'outer;
                     }
                 }
             }
@@ -5291,25 +5280,25 @@ impl Render for ProjectPanel {
                         .on_action(cx.listener(Self::paste))
                         .on_action(cx.listener(Self::duplicate))
                         .on_click(cx.listener(|this, event: &gpui::ClickEvent, window, cx| {
-                            if event.click_count() > 1 {
-                                if let Some(entry_id) = this.last_worktree_root_id {
-                                    let project = this.project.read(cx);
+                            if event.click_count() > 1
+                                && let Some(entry_id) = this.last_worktree_root_id
+                            {
+                                let project = this.project.read(cx);
 
-                                    let worktree_id = if let Some(worktree) =
-                                        project.worktree_for_entry(entry_id, cx)
-                                    {
-                                        worktree.read(cx).id()
-                                    } else {
-                                        return;
-                                    };
+                                let worktree_id = if let Some(worktree) =
+                                    project.worktree_for_entry(entry_id, cx)
+                                {
+                                    worktree.read(cx).id()
+                                } else {
+                                    return;
+                                };
 
-                                    this.selection = Some(SelectedEntry {
-                                        worktree_id,
-                                        entry_id,
-                                    });
+                                this.selection = Some(SelectedEntry {
+                                    worktree_id,
+                                    entry_id,
+                                });
 
-                                    this.new_file(&NewFile, window, cx);
-                                }
+                                this.new_file(&NewFile, window, cx);
                             }
                         }))
                 })

crates/prompt_store/src/prompts.rs πŸ”—

@@ -261,13 +261,12 @@ impl PromptBuilder {
                 // Initial scan of the prompt overrides directory
                 if let Ok(mut entries) = params.fs.read_dir(&templates_dir).await {
                     while let Some(Ok(file_path)) = entries.next().await {
-                        if file_path.to_string_lossy().ends_with(".hbs") {
-                            if let Ok(content) = params.fs.load(&file_path).await {
+                        if file_path.to_string_lossy().ends_with(".hbs")
+                            && let Ok(content) = params.fs.load(&file_path).await {
                                 let file_name = file_path.file_stem().unwrap().to_string_lossy();
                                 log::debug!("Registering prompt template override: {}", file_name);
                                 handlebars.lock().register_template_string(&file_name, content).log_err();
                             }
-                        }
                     }
                 }
 
@@ -280,13 +279,12 @@ impl PromptBuilder {
                 let mut combined_changes = futures::stream::select(changes, parent_changes);
 
                 while let Some(changed_paths) = combined_changes.next().await {
-                    if changed_paths.iter().any(|p| &p.path == &templates_dir) {
-                        if !params.fs.is_dir(&templates_dir).await {
+                    if changed_paths.iter().any(|p| &p.path == &templates_dir)
+                        && !params.fs.is_dir(&templates_dir).await {
                             log::info!("Prompt template overrides directory removed. Restoring built-in prompt templates.");
                             Self::register_built_in_templates(&mut handlebars.lock()).log_err();
                             break;
                         }
-                    }
                     for event in changed_paths {
                         if event.path.starts_with(&templates_dir) && event.path.extension().map_or(false, |ext| ext == "hbs") {
                             log::info!("Reloading prompt template override: {}", event.path.display());
@@ -311,12 +309,11 @@ impl PromptBuilder {
                 .split('/')
                 .next_back()
                 .and_then(|s| s.strip_suffix(".hbs"))
+                && let Some(prompt) = Assets.load(path.as_ref()).log_err().flatten()
             {
-                if let Some(prompt) = Assets.load(path.as_ref()).log_err().flatten() {
-                    log::debug!("Registering built-in prompt template: {}", id);
-                    let prompt = String::from_utf8_lossy(prompt.as_ref());
-                    handlebars.register_template_string(id, LineEnding::normalize_cow(prompt))?
-                }
+                log::debug!("Registering built-in prompt template: {}", id);
+                let prompt = String::from_utf8_lossy(prompt.as_ref());
+                handlebars.register_template_string(id, LineEnding::normalize_cow(prompt))?
             }
         }
 

crates/proto/src/error.rs πŸ”—

@@ -190,10 +190,10 @@ impl ErrorExt for RpcError {
     fn error_tag(&self, k: &str) -> Option<&str> {
         for tag in &self.tags {
             let mut parts = tag.split('=');
-            if let Some(key) = parts.next() {
-                if key == k {
-                    return parts.next();
-                }
+            if let Some(key) = parts.next()
+                && key == k
+            {
+                return parts.next();
             }
         }
         None

crates/recent_projects/src/remote_servers.rs πŸ”—

@@ -664,10 +664,10 @@ impl RemoteServerProjects {
                 let text = Some(state.editor.read(cx).text(cx)).filter(|text| !text.is_empty());
                 let index = state.index;
                 self.update_settings_file(cx, move |setting, _| {
-                    if let Some(connections) = setting.ssh_connections.as_mut() {
-                        if let Some(connection) = connections.get_mut(index) {
-                            connection.nickname = text;
-                        }
+                    if let Some(connections) = setting.ssh_connections.as_mut()
+                        && let Some(connection) = connections.get_mut(index)
+                    {
+                        connection.nickname = text;
                     }
                 });
                 self.mode = Mode::default_mode(&self.ssh_config_servers, cx);

crates/refineable/derive_refineable/src/derive_refineable.rs πŸ”—

@@ -510,12 +510,12 @@ fn is_refineable_field(f: &Field) -> bool {
 }
 
 fn is_optional_field(f: &Field) -> bool {
-    if let Type::Path(typepath) = &f.ty {
-        if typepath.qself.is_none() {
-            let segments = &typepath.path.segments;
-            if segments.len() == 1 && segments.iter().any(|s| s.ident == "Option") {
-                return true;
-            }
+    if let Type::Path(typepath) = &f.ty
+        && typepath.qself.is_none()
+    {
+        let segments = &typepath.path.segments;
+        if segments.len() == 1 && segments.iter().any(|s| s.ident == "Option") {
+            return true;
         }
     }
     false

crates/remote/src/ssh_session.rs πŸ”—

@@ -1310,10 +1310,10 @@ impl ConnectionPool {
                 return task.clone();
             }
             Some(ConnectionPoolEntry::Connected(ssh)) => {
-                if let Some(ssh) = ssh.upgrade() {
-                    if !ssh.has_been_killed() {
-                        return Task::ready(Ok(ssh)).shared();
-                    }
+                if let Some(ssh) = ssh.upgrade()
+                    && !ssh.has_been_killed()
+                {
+                    return Task::ready(Ok(ssh)).shared();
                 }
                 self.connections.remove(&opts);
             }
@@ -1840,26 +1840,25 @@ impl SshRemoteConnection {
             )),
             self.ssh_path_style,
         );
-        if !self.socket.connection_options.upload_binary_over_ssh {
-            if let Some((url, body)) = delegate
+        if !self.socket.connection_options.upload_binary_over_ssh
+            && let Some((url, body)) = delegate
                 .get_download_params(self.ssh_platform, release_channel, wanted_version, cx)
                 .await?
+        {
+            match self
+                .download_binary_on_server(&url, &body, &tmp_path_gz, delegate, cx)
+                .await
             {
-                match self
-                    .download_binary_on_server(&url, &body, &tmp_path_gz, delegate, cx)
-                    .await
-                {
-                    Ok(_) => {
-                        self.extract_server_binary(&dst_path, &tmp_path_gz, delegate, cx)
-                            .await?;
-                        return Ok(dst_path);
-                    }
-                    Err(e) => {
-                        log::error!(
-                            "Failed to download binary on server, attempting to upload server: {}",
-                            e
-                        )
-                    }
+                Ok(_) => {
+                    self.extract_server_binary(&dst_path, &tmp_path_gz, delegate, cx)
+                        .await?;
+                    return Ok(dst_path);
+                }
+                Err(e) => {
+                    log::error!(
+                        "Failed to download binary on server, attempting to upload server: {}",
+                        e
+                    )
                 }
             }
         }

crates/remote_server/src/unix.rs πŸ”—

@@ -951,13 +951,13 @@ fn cleanup_old_binaries() -> Result<()> {
     for entry in std::fs::read_dir(server_dir)? {
         let path = entry?.path();
 
-        if let Some(file_name) = path.file_name() {
-            if let Some(version) = file_name.to_string_lossy().strip_prefix(&prefix) {
-                if !is_new_version(version) && !is_file_in_use(file_name) {
-                    log::info!("removing old remote server binary: {:?}", path);
-                    std::fs::remove_file(&path)?;
-                }
-            }
+        if let Some(file_name) = path.file_name()
+            && let Some(version) = file_name.to_string_lossy().strip_prefix(&prefix)
+            && !is_new_version(version)
+            && !is_file_in_use(file_name)
+        {
+            log::info!("removing old remote server binary: {:?}", path);
+            std::fs::remove_file(&path)?;
         }
     }
 

crates/repl/src/kernels/native_kernel.rs πŸ”—

@@ -399,10 +399,10 @@ async fn read_kernels_dir(path: PathBuf, fs: &dyn Fs) -> Result<Vec<LocalKernelS
     while let Some(path) = kernelspec_dirs.next().await {
         match path {
             Ok(path) => {
-                if fs.is_dir(path.as_path()).await {
-                    if let Ok(kernelspec) = read_kernelspec_at(path, fs).await {
-                        valid_kernelspecs.push(kernelspec);
-                    }
+                if fs.is_dir(path.as_path()).await
+                    && let Ok(kernelspec) = read_kernelspec_at(path, fs).await
+                {
+                    valid_kernelspecs.push(kernelspec);
                 }
             }
             Err(err) => log::warn!("Error reading kernelspec directory: {err:?}"),
@@ -429,14 +429,14 @@ pub async fn local_kernel_specifications(fs: Arc<dyn Fs>) -> Result<Vec<LocalKer
         .output()
         .await;
 
-    if let Ok(command) = command {
-        if command.status.success() {
-            let python_prefix = String::from_utf8(command.stdout);
-            if let Ok(python_prefix) = python_prefix {
-                let python_prefix = PathBuf::from(python_prefix.trim());
-                let python_data_dir = python_prefix.join("share").join("jupyter");
-                data_dirs.push(python_data_dir);
-            }
+    if let Ok(command) = command
+        && command.status.success()
+    {
+        let python_prefix = String::from_utf8(command.stdout);
+        if let Ok(python_prefix) = python_prefix {
+            let python_prefix = PathBuf::from(python_prefix.trim());
+            let python_data_dir = python_prefix.join("share").join("jupyter");
+            data_dirs.push(python_data_dir);
         }
     }
 

crates/repl/src/outputs.rs πŸ”—

@@ -412,10 +412,10 @@ impl ExecutionView {
         };
 
         // Check for a clear output marker as the previous output, so we can clear it out
-        if let Some(output) = self.outputs.last() {
-            if let Output::ClearOutputWaitMarker = output {
-                self.outputs.clear();
-            }
+        if let Some(output) = self.outputs.last()
+            && let Output::ClearOutputWaitMarker = output
+        {
+            self.outputs.clear();
         }
 
         self.outputs.push(output);
@@ -433,11 +433,11 @@ impl ExecutionView {
         let mut any = false;
 
         self.outputs.iter_mut().for_each(|output| {
-            if let Some(other_display_id) = output.display_id().as_ref() {
-                if other_display_id == display_id {
-                    *output = Output::new(data, Some(display_id.to_owned()), window, cx);
-                    any = true;
-                }
+            if let Some(other_display_id) = output.display_id().as_ref()
+                && other_display_id == display_id
+            {
+                *output = Output::new(data, Some(display_id.to_owned()), window, cx);
+                any = true;
             }
         });
 
@@ -452,19 +452,18 @@ impl ExecutionView {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) -> Option<Output> {
-        if let Some(last_output) = self.outputs.last_mut() {
-            if let Output::Stream {
+        if let Some(last_output) = self.outputs.last_mut()
+            && let Output::Stream {
                 content: last_stream,
             } = last_output
-            {
-                // Don't need to add a new output, we already have a terminal output
-                // and can just update the most recent terminal output
-                last_stream.update(cx, |last_stream, cx| {
-                    last_stream.append_text(text, cx);
-                    cx.notify();
-                });
-                return None;
-            }
+        {
+            // Don't need to add a new output, we already have a terminal output
+            // and can just update the most recent terminal output
+            last_stream.update(cx, |last_stream, cx| {
+                last_stream.append_text(text, cx);
+                cx.notify();
+            });
+            return None;
         }
 
         Some(Output::Stream {

crates/repl/src/repl_editor.rs πŸ”—

@@ -417,10 +417,10 @@ fn runnable_ranges(
     range: Range<Point>,
     cx: &mut App,
 ) -> (Vec<Range<Point>>, Option<Point>) {
-    if let Some(language) = buffer.language() {
-        if language.name() == "Markdown".into() {
-            return (markdown_code_blocks(buffer, range.clone(), cx), None);
-        }
+    if let Some(language) = buffer.language()
+        && language.name() == "Markdown".into()
+    {
+        return (markdown_code_blocks(buffer, range.clone(), cx), None);
     }
 
     let (jupytext_snippets, next_cursor) = jupytext_cells(buffer, range.clone());

crates/repl/src/repl_sessions_ui.rs πŸ”—

@@ -102,21 +102,16 @@ pub fn init(cx: &mut App) {
 
                 let editor_handle = cx.entity().downgrade();
 
-                if let Some(language) = language {
-                    if language.name() == "Python".into() {
-                        if let (Some(project_path), Some(project)) = (project_path, project) {
-                            let store = ReplStore::global(cx);
-                            store.update(cx, |store, cx| {
-                                store
-                                    .refresh_python_kernelspecs(
-                                        project_path.worktree_id,
-                                        &project,
-                                        cx,
-                                    )
-                                    .detach_and_log_err(cx);
-                            });
-                        }
-                    }
+                if let Some(language) = language
+                    && language.name() == "Python".into()
+                    && let (Some(project_path), Some(project)) = (project_path, project)
+                {
+                    let store = ReplStore::global(cx);
+                    store.update(cx, |store, cx| {
+                        store
+                            .refresh_python_kernelspecs(project_path.worktree_id, &project, cx)
+                            .detach_and_log_err(cx);
+                    });
                 }
 
                 editor

crates/repl/src/repl_store.rs πŸ”—

@@ -171,10 +171,10 @@ impl ReplStore {
                 .map(KernelSpecification::Jupyter)
                 .collect::<Vec<_>>();
 
-            if let Some(remote_task) = remote_kernel_specifications {
-                if let Ok(remote_specs) = remote_task.await {
-                    all_specs.extend(remote_specs);
-                }
+            if let Some(remote_task) = remote_kernel_specifications
+                && let Ok(remote_specs) = remote_task.await
+            {
+                all_specs.extend(remote_specs);
             }
 
             anyhow::Ok(all_specs)

crates/reqwest_client/src/reqwest_client.rs πŸ”—

@@ -201,12 +201,11 @@ pub fn poll_read_buf(
 }
 
 fn redact_error(mut error: reqwest::Error) -> reqwest::Error {
-    if let Some(url) = error.url_mut() {
-        if let Some(query) = url.query() {
-            if let Cow::Owned(redacted) = REDACT_REGEX.replace_all(query, "key=REDACTED") {
-                url.set_query(Some(redacted.as_str()));
-            }
-        }
+    if let Some(url) = error.url_mut()
+        && let Some(query) = url.query()
+        && let Cow::Owned(redacted) = REDACT_REGEX.replace_all(query, "key=REDACTED")
+    {
+        url.set_query(Some(redacted.as_str()));
     }
     error
 }

crates/rich_text/src/rich_text.rs πŸ”—

@@ -162,10 +162,10 @@ impl RichText {
                     }
                 }
                 for range in &custom_tooltip_ranges {
-                    if range.contains(&idx) {
-                        if let Some(f) = &custom_tooltip_fn {
-                            return f(idx, range.clone(), window, cx);
-                        }
+                    if range.contains(&idx)
+                        && let Some(f) = &custom_tooltip_fn
+                    {
+                        return f(idx, range.clone(), window, cx);
                     }
                 }
                 None
@@ -281,13 +281,12 @@ pub fn render_markdown_mut(
 
                     if style != HighlightStyle::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
-                                && last_style == &Highlight::Highlight(style)
-                            {
-                                last_range.end = text.len();
-                                new_highlight = false;
-                            }
+                        if let Some((last_range, last_style)) = highlights.last_mut()
+                            && last_range.end == last_run_len
+                            && last_style == &Highlight::Highlight(style)
+                        {
+                            last_range.end = text.len();
+                            new_highlight = false;
                         }
                         if new_highlight {
                             highlights

crates/rope/src/rope.rs πŸ”—

@@ -31,22 +31,21 @@ impl Rope {
     }
 
     pub fn append(&mut self, rope: Rope) {
-        if let Some(chunk) = rope.chunks.first() {
-            if self
+        if let Some(chunk) = rope.chunks.first()
+            && (self
                 .chunks
                 .last()
                 .map_or(false, |c| c.text.len() < chunk::MIN_BASE)
-                || chunk.text.len() < chunk::MIN_BASE
-            {
-                self.push_chunk(chunk.as_slice());
-
-                let mut chunks = rope.chunks.cursor::<()>(&());
-                chunks.next();
-                chunks.next();
-                self.chunks.append(chunks.suffix(), &());
-                self.check_invariants();
-                return;
-            }
+                || chunk.text.len() < chunk::MIN_BASE)
+        {
+            self.push_chunk(chunk.as_slice());
+
+            let mut chunks = rope.chunks.cursor::<()>(&());
+            chunks.next();
+            chunks.next();
+            self.chunks.append(chunks.suffix(), &());
+            self.check_invariants();
+            return;
         }
 
         self.chunks.append(rope.chunks.clone(), &());
@@ -735,16 +734,16 @@ impl<'a> Chunks<'a> {
         self.chunks
             .search_backward(|summary| summary.text.lines.row > 0);
         self.offset = *self.chunks.start();
-        if let Some(chunk) = self.chunks.item() {
-            if let Some(newline_ix) = chunk.text.rfind('\n') {
-                self.offset += newline_ix + 1;
-                if self.offset_is_valid() {
-                    if self.offset == self.chunks.end() {
-                        self.chunks.next();
-                    }
-
-                    return true;
+        if let Some(chunk) = self.chunks.item()
+            && let Some(newline_ix) = chunk.text.rfind('\n')
+        {
+            self.offset += newline_ix + 1;
+            if self.offset_is_valid() {
+                if self.offset == self.chunks.end() {
+                    self.chunks.next();
                 }
+
+                return true;
             }
         }
 

crates/rpc/src/notification.rs πŸ”—

@@ -48,10 +48,10 @@ impl Notification {
         let Some(Value::String(kind)) = value.remove(KIND) else {
             unreachable!("kind is the enum tag")
         };
-        if let map::Entry::Occupied(e) = value.entry(ENTITY_ID) {
-            if e.get().is_u64() {
-                entity_id = e.remove().as_u64();
-            }
+        if let map::Entry::Occupied(e) = value.entry(ENTITY_ID)
+            && e.get().is_u64()
+        {
+            entity_id = e.remove().as_u64();
         }
         proto::Notification {
             kind,

crates/rpc/src/peer.rs πŸ”—

@@ -520,10 +520,10 @@ impl Peer {
                             &response.payload
                         {
                             // Remove the transmitting end of the response channel to end the stream.
-                            if let Some(channels) = stream_response_channels.upgrade() {
-                                if let Some(channels) = channels.lock().as_mut() {
-                                    channels.remove(&message_id);
-                                }
+                            if let Some(channels) = stream_response_channels.upgrade()
+                                && let Some(channels) = channels.lock().as_mut()
+                            {
+                                channels.remove(&message_id);
                             }
                             None
                         } else {

crates/rules_library/src/rules_library.rs πŸ”—

@@ -456,11 +456,11 @@ impl RulesLibrary {
     pub fn new_rule(&mut self, window: &mut Window, cx: &mut Context<Self>) {
         // If we already have an untitled rule, use that instead
         // of creating a new one.
-        if let Some(metadata) = self.store.read(cx).first() {
-            if metadata.title.is_none() {
-                self.load_rule(metadata.id, true, window, cx);
-                return;
-            }
+        if let Some(metadata) = self.store.read(cx).first()
+            && metadata.title.is_none()
+        {
+            self.load_rule(metadata.id, true, window, cx);
+            return;
         }
 
         let prompt_id = PromptId::new();
@@ -706,15 +706,13 @@ impl RulesLibrary {
                     .map_or(true, |old_selected_prompt| {
                         old_selected_prompt.id != prompt_id
                     })
-                {
-                    if let Some(ix) = picker
+                    && let Some(ix) = picker
                         .delegate
                         .matches
                         .iter()
                         .position(|mat| mat.id == prompt_id)
-                    {
-                        picker.set_selected_index(ix, None, true, window, cx);
-                    }
+                {
+                    picker.set_selected_index(ix, None, true, window, cx);
                 }
             } else {
                 picker.focus(window, cx);
@@ -869,10 +867,10 @@ impl RulesLibrary {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(rule_id) = self.active_rule_id {
-            if let Some(rule_editor) = self.rule_editors.get(&rule_id) {
-                window.focus(&rule_editor.body_editor.focus_handle(cx));
-            }
+        if let Some(rule_id) = self.active_rule_id
+            && let Some(rule_editor) = self.rule_editors.get(&rule_id)
+        {
+            window.focus(&rule_editor.body_editor.focus_handle(cx));
         }
     }
 
@@ -882,10 +880,10 @@ impl RulesLibrary {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(rule_id) = self.active_rule_id {
-            if let Some(rule_editor) = self.rule_editors.get(&rule_id) {
-                window.focus(&rule_editor.title_editor.focus_handle(cx));
-            }
+        if let Some(rule_id) = self.active_rule_id
+            && let Some(rule_editor) = self.rule_editors.get(&rule_id)
+        {
+            window.focus(&rule_editor.title_editor.focus_handle(cx));
         }
     }
 

crates/search/src/buffer_search.rs πŸ”—

@@ -794,15 +794,13 @@ impl BufferSearchBar {
     }
 
     pub fn activate_current_match(&mut self, window: &mut Window, cx: &mut Context<Self>) {
-        if let Some(match_ix) = self.active_match_index {
-            if let Some(active_searchable_item) = self.active_searchable_item.as_ref() {
-                if let Some(matches) = self
-                    .searchable_items_with_matches
-                    .get(&active_searchable_item.downgrade())
-                {
-                    active_searchable_item.activate_match(match_ix, matches, window, cx)
-                }
-            }
+        if let Some(match_ix) = self.active_match_index
+            && let Some(active_searchable_item) = self.active_searchable_item.as_ref()
+            && let Some(matches) = self
+                .searchable_items_with_matches
+                .get(&active_searchable_item.downgrade())
+        {
+            active_searchable_item.activate_match(match_ix, matches, window, cx)
         }
     }
 
@@ -951,16 +949,15 @@ impl BufferSearchBar {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if !self.dismissed && self.active_match_index.is_some() {
-            if let Some(searchable_item) = self.active_searchable_item.as_ref() {
-                if let Some(matches) = self
-                    .searchable_items_with_matches
-                    .get(&searchable_item.downgrade())
-                {
-                    searchable_item.select_matches(matches, window, cx);
-                    self.focus_editor(&FocusEditor, window, cx);
-                }
-            }
+        if !self.dismissed
+            && self.active_match_index.is_some()
+            && let Some(searchable_item) = self.active_searchable_item.as_ref()
+            && let Some(matches) = self
+                .searchable_items_with_matches
+                .get(&searchable_item.downgrade())
+        {
+            searchable_item.select_matches(matches, window, cx);
+            self.focus_editor(&FocusEditor, window, cx);
         }
     }
 
@@ -971,59 +968,55 @@ impl BufferSearchBar {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(index) = self.active_match_index {
-            if let Some(searchable_item) = self.active_searchable_item.as_ref() {
-                if let Some(matches) = self
-                    .searchable_items_with_matches
-                    .get(&searchable_item.downgrade())
-                    .filter(|matches| !matches.is_empty())
-                {
-                    // If 'wrapscan' is disabled, searches do not wrap around the end of the file.
-                    if !EditorSettings::get_global(cx).search_wrap
-                        && ((direction == Direction::Next && index + count >= matches.len())
-                            || (direction == Direction::Prev && index < count))
-                    {
-                        crate::show_no_more_matches(window, cx);
-                        return;
-                    }
-                    let new_match_index = searchable_item
-                        .match_index_for_direction(matches, index, direction, count, window, cx);
-
-                    searchable_item.update_matches(matches, window, cx);
-                    searchable_item.activate_match(new_match_index, matches, window, cx);
-                }
+        if let Some(index) = self.active_match_index
+            && let Some(searchable_item) = self.active_searchable_item.as_ref()
+            && let Some(matches) = self
+                .searchable_items_with_matches
+                .get(&searchable_item.downgrade())
+                .filter(|matches| !matches.is_empty())
+        {
+            // If 'wrapscan' is disabled, searches do not wrap around the end of the file.
+            if !EditorSettings::get_global(cx).search_wrap
+                && ((direction == Direction::Next && index + count >= matches.len())
+                    || (direction == Direction::Prev && index < count))
+            {
+                crate::show_no_more_matches(window, cx);
+                return;
             }
+            let new_match_index = searchable_item
+                .match_index_for_direction(matches, index, direction, count, window, cx);
+
+            searchable_item.update_matches(matches, window, cx);
+            searchable_item.activate_match(new_match_index, matches, window, cx);
         }
     }
 
     pub fn select_first_match(&mut self, window: &mut Window, cx: &mut Context<Self>) {
-        if let Some(searchable_item) = self.active_searchable_item.as_ref() {
-            if let Some(matches) = self
+        if let Some(searchable_item) = self.active_searchable_item.as_ref()
+            && let Some(matches) = self
                 .searchable_items_with_matches
                 .get(&searchable_item.downgrade())
-            {
-                if matches.is_empty() {
-                    return;
-                }
-                searchable_item.update_matches(matches, window, cx);
-                searchable_item.activate_match(0, matches, window, cx);
+        {
+            if matches.is_empty() {
+                return;
             }
+            searchable_item.update_matches(matches, window, cx);
+            searchable_item.activate_match(0, matches, window, cx);
         }
     }
 
     pub fn select_last_match(&mut self, window: &mut Window, cx: &mut Context<Self>) {
-        if let Some(searchable_item) = self.active_searchable_item.as_ref() {
-            if let Some(matches) = self
+        if let Some(searchable_item) = self.active_searchable_item.as_ref()
+            && let Some(matches) = self
                 .searchable_items_with_matches
                 .get(&searchable_item.downgrade())
-            {
-                if matches.is_empty() {
-                    return;
-                }
-                let new_match_index = matches.len() - 1;
-                searchable_item.update_matches(matches, window, cx);
-                searchable_item.activate_match(new_match_index, matches, window, cx);
+        {
+            if matches.is_empty() {
+                return;
             }
+            let new_match_index = matches.len() - 1;
+            searchable_item.update_matches(matches, window, cx);
+            searchable_item.activate_match(new_match_index, matches, window, cx);
         }
     }
 
@@ -1344,15 +1337,14 @@ impl BufferSearchBar {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if self.query(cx).is_empty() {
-            if let Some(new_query) = self
+        if self.query(cx).is_empty()
+            && let Some(new_query) = self
                 .search_history
                 .current(&mut self.search_history_cursor)
                 .map(str::to_string)
-            {
-                drop(self.search(&new_query, Some(self.search_options), window, cx));
-                return;
-            }
+        {
+            drop(self.search(&new_query, Some(self.search_options), window, cx));
+            return;
         }
 
         if let Some(new_query) = self
@@ -1384,25 +1376,23 @@ impl BufferSearchBar {
 
     fn replace_next(&mut self, _: &ReplaceNext, window: &mut Window, cx: &mut Context<Self>) {
         let mut should_propagate = true;
-        if !self.dismissed && self.active_search.is_some() {
-            if let Some(searchable_item) = self.active_searchable_item.as_ref() {
-                if let Some(query) = self.active_search.as_ref() {
-                    if let Some(matches) = self
-                        .searchable_items_with_matches
-                        .get(&searchable_item.downgrade())
-                    {
-                        if let Some(active_index) = self.active_match_index {
-                            let query = query
-                                .as_ref()
-                                .clone()
-                                .with_replacement(self.replacement(cx));
-                            searchable_item.replace(matches.at(active_index), &query, window, cx);
-                            self.select_next_match(&SelectNextMatch, window, cx);
-                        }
-                        should_propagate = false;
-                    }
-                }
+        if !self.dismissed
+            && self.active_search.is_some()
+            && let Some(searchable_item) = self.active_searchable_item.as_ref()
+            && let Some(query) = self.active_search.as_ref()
+            && let Some(matches) = self
+                .searchable_items_with_matches
+                .get(&searchable_item.downgrade())
+        {
+            if let Some(active_index) = self.active_match_index {
+                let query = query
+                    .as_ref()
+                    .clone()
+                    .with_replacement(self.replacement(cx));
+                searchable_item.replace(matches.at(active_index), &query, window, cx);
+                self.select_next_match(&SelectNextMatch, window, cx);
             }
+            should_propagate = false;
         }
         if !should_propagate {
             cx.stop_propagation();
@@ -1410,21 +1400,19 @@ impl BufferSearchBar {
     }
 
     pub fn replace_all(&mut self, _: &ReplaceAll, window: &mut Window, cx: &mut Context<Self>) {
-        if !self.dismissed && self.active_search.is_some() {
-            if let Some(searchable_item) = self.active_searchable_item.as_ref() {
-                if let Some(query) = self.active_search.as_ref() {
-                    if let Some(matches) = self
-                        .searchable_items_with_matches
-                        .get(&searchable_item.downgrade())
-                    {
-                        let query = query
-                            .as_ref()
-                            .clone()
-                            .with_replacement(self.replacement(cx));
-                        searchable_item.replace_all(&mut matches.iter(), &query, window, cx);
-                    }
-                }
-            }
+        if !self.dismissed
+            && self.active_search.is_some()
+            && let Some(searchable_item) = self.active_searchable_item.as_ref()
+            && let Some(query) = self.active_search.as_ref()
+            && let Some(matches) = self
+                .searchable_items_with_matches
+                .get(&searchable_item.downgrade())
+        {
+            let query = query
+                .as_ref()
+                .clone()
+                .with_replacement(self.replacement(cx));
+            searchable_item.replace_all(&mut matches.iter(), &query, window, cx);
         }
     }
 

crates/search/src/project_search.rs πŸ”—

@@ -775,15 +775,15 @@ impl ProjectSearchView {
         // Subscribe to query_editor in order to reraise editor events for workspace item activation purposes
         subscriptions.push(
             cx.subscribe(&query_editor, |this, _, event: &EditorEvent, cx| {
-                if let EditorEvent::Edited { .. } = event {
-                    if EditorSettings::get_global(cx).use_smartcase_search {
-                        let query = this.search_query_text(cx);
-                        if !query.is_empty()
-                            && this.search_options.contains(SearchOptions::CASE_SENSITIVE)
-                                != contains_uppercase(&query)
-                        {
-                            this.toggle_search_option(SearchOptions::CASE_SENSITIVE, cx);
-                        }
+                if let EditorEvent::Edited { .. } = event
+                    && EditorSettings::get_global(cx).use_smartcase_search
+                {
+                    let query = this.search_query_text(cx);
+                    if !query.is_empty()
+                        && this.search_options.contains(SearchOptions::CASE_SENSITIVE)
+                            != contains_uppercase(&query)
+                    {
+                        this.toggle_search_option(SearchOptions::CASE_SENSITIVE, cx);
                     }
                 }
                 cx.emit(ViewEvent::EditorEvent(event.clone()))
@@ -947,14 +947,14 @@ impl ProjectSearchView {
         {
             let new_query = search_view.update(cx, |search_view, cx| {
                 let new_query = search_view.build_search_query(cx);
-                if new_query.is_some() {
-                    if let Some(old_query) = search_view.entity.read(cx).active_query.clone() {
-                        search_view.query_editor.update(cx, |editor, cx| {
-                            editor.set_text(old_query.as_str(), window, cx);
-                        });
-                        search_view.search_options = SearchOptions::from_query(&old_query);
-                        search_view.adjust_query_regex_language(cx);
-                    }
+                if new_query.is_some()
+                    && let Some(old_query) = search_view.entity.read(cx).active_query.clone()
+                {
+                    search_view.query_editor.update(cx, |editor, cx| {
+                        editor.set_text(old_query.as_str(), window, cx);
+                    });
+                    search_view.search_options = SearchOptions::from_query(&old_query);
+                    search_view.adjust_query_regex_language(cx);
                 }
                 new_query
             });
@@ -1844,8 +1844,8 @@ impl ProjectSearchBar {
                     ),
                 ] {
                     if editor.focus_handle(cx).is_focused(window) {
-                        if editor.read(cx).text(cx).is_empty() {
-                            if let Some(new_query) = search_view
+                        if editor.read(cx).text(cx).is_empty()
+                            && let Some(new_query) = search_view
                                 .entity
                                 .read(cx)
                                 .project
@@ -1853,10 +1853,9 @@ impl ProjectSearchBar {
                                 .search_history(kind)
                                 .current(search_view.entity.read(cx).cursor(kind))
                                 .map(str::to_string)
-                            {
-                                search_view.set_search_editor(kind, &new_query, window, cx);
-                                return;
-                            }
+                        {
+                            search_view.set_search_editor(kind, &new_query, window, cx);
+                            return;
                         }
 
                         if let Some(new_query) = search_view.entity.update(cx, |model, cx| {

crates/semantic_index/src/embedding_index.rs πŸ”—

@@ -194,11 +194,11 @@ impl EmbeddingIndex {
                     project::PathChange::Added
                     | project::PathChange::Updated
                     | project::PathChange::AddedOrUpdated => {
-                        if let Some(entry) = worktree.entry_for_id(*entry_id) {
-                            if entry.is_file() {
-                                let handle = entries_being_indexed.insert(entry.id);
-                                updated_entries_tx.send((entry.clone(), handle)).await?;
-                            }
+                        if let Some(entry) = worktree.entry_for_id(*entry_id)
+                            && entry.is_file()
+                        {
+                            let handle = entries_being_indexed.insert(entry.id);
+                            updated_entries_tx.send((entry.clone(), handle)).await?;
                         }
                     }
                     project::PathChange::Removed => {

crates/semantic_index/src/project_index.rs πŸ”—

@@ -384,10 +384,10 @@ impl ProjectIndex {
         cx: &App,
     ) -> Option<Entity<WorktreeIndex>> {
         for index in self.worktree_indices.values() {
-            if let WorktreeIndexHandle::Loaded { index, .. } = index {
-                if index.read(cx).worktree().read(cx).id() == worktree_id {
-                    return Some(index.clone());
-                }
+            if let WorktreeIndexHandle::Loaded { index, .. } = index
+                && index.read(cx).worktree().read(cx).id() == worktree_id
+            {
+                return Some(index.clone());
             }
         }
         None

crates/semantic_index/src/semantic_index.rs πŸ”—

@@ -174,14 +174,13 @@ impl SemanticDb {
                 file_content[start_line_byte_offset..end_line_byte_offset].to_string();
             LineEnding::normalize(&mut excerpt_content);
 
-            if let Some(prev_result) = loaded_results.last_mut() {
-                if prev_result.full_path == full_path {
-                    if *prev_result.row_range.end() + 1 == start_row {
-                        prev_result.row_range = *prev_result.row_range.start()..=end_row;
-                        prev_result.excerpt_content.push_str(&excerpt_content);
-                        continue;
-                    }
-                }
+            if let Some(prev_result) = loaded_results.last_mut()
+                && prev_result.full_path == full_path
+                && *prev_result.row_range.end() + 1 == start_row
+            {
+                prev_result.row_range = *prev_result.row_range.start()..=end_row;
+                prev_result.excerpt_content.push_str(&excerpt_content);
+                continue;
             }
 
             loaded_results.push(LoadedSearchResult {

crates/semantic_index/src/summary_index.rs πŸ”—

@@ -379,18 +379,14 @@ impl SummaryIndex {
                     | project::PathChange::Added
                     | project::PathChange::Updated
                     | project::PathChange::AddedOrUpdated => {
-                        if let Some(entry) = worktree.entry_for_id(*entry_id) {
-                            if entry.is_file() {
-                                let needs_summary = Self::add_to_backlog(
-                                    Arc::clone(&backlog),
-                                    digest_db,
-                                    &txn,
-                                    entry,
-                                );
-
-                                if !needs_summary.is_empty() {
-                                    tx.send(needs_summary).await?;
-                                }
+                        if let Some(entry) = worktree.entry_for_id(*entry_id)
+                            && entry.is_file()
+                        {
+                            let needs_summary =
+                                Self::add_to_backlog(Arc::clone(&backlog), digest_db, &txn, entry);
+
+                            if !needs_summary.is_empty() {
+                                tx.send(needs_summary).await?;
                             }
                         }
                     }

crates/session/src/session.rs πŸ”—

@@ -70,11 +70,11 @@ impl AppSession {
         let _serialization_task = cx.spawn(async move |_, cx| {
             let mut current_window_stack = Vec::new();
             loop {
-                if let Some(windows) = cx.update(|cx| window_stack(cx)).ok().flatten() {
-                    if windows != current_window_stack {
-                        store_window_stack(&windows).await;
-                        current_window_stack = windows;
-                    }
+                if let Some(windows) = cx.update(|cx| window_stack(cx)).ok().flatten()
+                    && windows != current_window_stack
+                {
+                    store_window_stack(&windows).await;
+                    current_window_stack = windows;
                 }
 
                 cx.background_executor()

crates/settings/src/keymap_file.rs πŸ”—

@@ -543,27 +543,27 @@ impl KeymapFile {
             //
             // When a struct with no deserializable fields is added by deriving `Action`, an empty
             // object schema is produced. The action should be invoked without data in this case.
-            if let Some(schema) = action_schema {
-                if schema != empty_object {
-                    let mut matches_action_name = json_schema!({
-                        "const": name
-                    });
-                    if let Some(desc) = description.clone() {
-                        add_description(&mut matches_action_name, desc);
-                    }
-                    if let Some(message) = deprecation_messages.get(name) {
-                        add_deprecation(&mut matches_action_name, message.to_string());
-                    } else if let Some(new_name) = deprecation {
-                        add_deprecation_preferred_name(&mut matches_action_name, new_name);
-                    }
-                    let action_with_input = json_schema!({
-                        "type": "array",
-                        "items": [matches_action_name, schema],
-                        "minItems": 2,
-                        "maxItems": 2
-                    });
-                    keymap_action_alternatives.push(action_with_input);
+            if let Some(schema) = action_schema
+                && schema != empty_object
+            {
+                let mut matches_action_name = json_schema!({
+                    "const": name
+                });
+                if let Some(desc) = description.clone() {
+                    add_description(&mut matches_action_name, desc);
                 }
+                if let Some(message) = deprecation_messages.get(name) {
+                    add_deprecation(&mut matches_action_name, message.to_string());
+                } else if let Some(new_name) = deprecation {
+                    add_deprecation_preferred_name(&mut matches_action_name, new_name);
+                }
+                let action_with_input = json_schema!({
+                    "type": "array",
+                    "items": [matches_action_name, schema],
+                    "minItems": 2,
+                    "maxItems": 2
+                });
+                keymap_action_alternatives.push(action_with_input);
             }
         }
 
@@ -593,10 +593,10 @@ impl KeymapFile {
         match fs.load(paths::keymap_file()).await {
             result @ Ok(_) => result,
             Err(err) => {
-                if let Some(e) = err.downcast_ref::<std::io::Error>() {
-                    if e.kind() == std::io::ErrorKind::NotFound {
-                        return Ok(crate::initial_keymap_content().to_string());
-                    }
+                if let Some(e) = err.downcast_ref::<std::io::Error>()
+                    && e.kind() == std::io::ErrorKind::NotFound
+                {
+                    return Ok(crate::initial_keymap_content().to_string());
                 }
                 Err(err)
             }

crates/settings/src/settings_file.rs πŸ”—

@@ -67,10 +67,10 @@ pub fn watch_config_file(
                     break;
                 }
 
-                if let Ok(contents) = fs.load(&path).await {
-                    if tx.unbounded_send(contents).is_err() {
-                        break;
-                    }
+                if let Ok(contents) = fs.load(&path).await
+                    && tx.unbounded_send(contents).is_err()
+                {
+                    break;
                 }
             }
         })
@@ -88,12 +88,11 @@ pub fn watch_config_dir(
     executor
         .spawn(async move {
             for file_path in &config_paths {
-                if fs.metadata(file_path).await.is_ok_and(|v| v.is_some()) {
-                    if let Ok(contents) = fs.load(file_path).await {
-                        if tx.unbounded_send(contents).is_err() {
-                            return;
-                        }
-                    }
+                if fs.metadata(file_path).await.is_ok_and(|v| v.is_some())
+                    && let Ok(contents) = fs.load(file_path).await
+                    && tx.unbounded_send(contents).is_err()
+                {
+                    return;
                 }
             }
 
@@ -110,10 +109,10 @@ pub fn watch_config_dir(
                                 }
                             }
                             Some(PathEventKind::Created) | Some(PathEventKind::Changed) => {
-                                if let Ok(contents) = fs.load(&event.path).await {
-                                    if tx.unbounded_send(contents).is_err() {
-                                        return;
-                                    }
+                                if let Ok(contents) = fs.load(&event.path).await
+                                    && tx.unbounded_send(contents).is_err()
+                                {
+                                    return;
                                 }
                             }
                             _ => {}

crates/settings/src/settings_json.rs πŸ”—

@@ -369,13 +369,12 @@ pub fn replace_top_level_array_value_in_json_text(
             if cursor.node().kind() == "," {
                 remove_range.end = cursor.node().range().end_byte;
             }
-            if let Some(next_newline) = &text[remove_range.end + 1..].find('\n') {
-                if text[remove_range.end + 1..remove_range.end + next_newline]
+            if let Some(next_newline) = &text[remove_range.end + 1..].find('\n')
+                && text[remove_range.end + 1..remove_range.end + next_newline]
                     .chars()
                     .all(|c| c.is_ascii_whitespace())
-                {
-                    remove_range.end = remove_range.end + next_newline;
-                }
+            {
+                remove_range.end = remove_range.end + next_newline;
             }
         } else {
             while cursor.goto_previous_sibling()
@@ -508,10 +507,10 @@ pub fn append_top_level_array_value_in_json_text(
             replace_value.insert(0, ',');
         }
     } else {
-        if let Some(prev_newline) = text[..replace_range.start].rfind('\n') {
-            if text[prev_newline..replace_range.start].trim().is_empty() {
-                replace_range.start = prev_newline;
-            }
+        if let Some(prev_newline) = text[..replace_range.start].rfind('\n')
+            && text[prev_newline..replace_range.start].trim().is_empty()
+        {
+            replace_range.start = prev_newline;
         }
         let indent = format!("\n{space:width$}", width = tab_size);
         replace_value = replace_value.replace('\n', &indent);

crates/settings/src/settings_store.rs πŸ”—

@@ -346,14 +346,13 @@ impl SettingsStore {
             }
 
             let mut profile_value = None;
-            if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() {
-                if let Some(profiles) = self.raw_user_settings.get("profiles") {
-                    if let Some(profile_settings) = profiles.get(&active_profile.0) {
-                        profile_value = setting_value
-                            .deserialize_setting(profile_settings)
-                            .log_err();
-                    }
-                }
+            if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>()
+                && let Some(profiles) = self.raw_user_settings.get("profiles")
+                && let Some(profile_settings) = profiles.get(&active_profile.0)
+            {
+                profile_value = setting_value
+                    .deserialize_setting(profile_settings)
+                    .log_err();
             }
 
             let server_value = self
@@ -482,10 +481,10 @@ impl SettingsStore {
         match fs.load(paths::settings_file()).await {
             result @ Ok(_) => result,
             Err(err) => {
-                if let Some(e) = err.downcast_ref::<std::io::Error>() {
-                    if e.kind() == std::io::ErrorKind::NotFound {
-                        return Ok(crate::initial_user_settings_content().to_string());
-                    }
+                if let Some(e) = err.downcast_ref::<std::io::Error>()
+                    && e.kind() == std::io::ErrorKind::NotFound
+                {
+                    return Ok(crate::initial_user_settings_content().to_string());
                 }
                 Err(err)
             }
@@ -496,10 +495,10 @@ impl SettingsStore {
         match fs.load(paths::global_settings_file()).await {
             result @ Ok(_) => result,
             Err(err) => {
-                if let Some(e) = err.downcast_ref::<std::io::Error>() {
-                    if e.kind() == std::io::ErrorKind::NotFound {
-                        return Ok("{}".to_string());
-                    }
+                if let Some(e) = err.downcast_ref::<std::io::Error>()
+                    && e.kind() == std::io::ErrorKind::NotFound
+                {
+                    return Ok("{}".to_string());
                 }
                 Err(err)
             }
@@ -955,13 +954,13 @@ impl SettingsStore {
             let mut setting_schema = setting_value.json_schema(&mut generator);
 
             if let Some(key) = setting_value.key() {
-                if let Some(properties) = combined_schema.get_mut("properties") {
-                    if let Some(properties_obj) = properties.as_object_mut() {
-                        if let Some(target) = properties_obj.get_mut(key) {
-                            merge_schema(target, setting_schema.to_value());
-                        } else {
-                            properties_obj.insert(key.to_string(), setting_schema.to_value());
-                        }
+                if let Some(properties) = combined_schema.get_mut("properties")
+                    && let Some(properties_obj) = properties.as_object_mut()
+                {
+                    if let Some(target) = properties_obj.get_mut(key) {
+                        merge_schema(target, setting_schema.to_value());
+                    } else {
+                        properties_obj.insert(key.to_string(), setting_schema.to_value());
                     }
                 }
             } else {
@@ -1038,16 +1037,15 @@ impl SettingsStore {
                     | "additionalProperties" => {
                         if let Some(old_value) =
                             target_obj.insert(source_key.clone(), source_value.clone())
+                            && old_value != source_value
                         {
-                            if old_value != source_value {
-                                log::error!(
-                                    "bug: while merging JSON schemas, \
+                            log::error!(
+                                "bug: while merging JSON schemas, \
                                     mismatch `\"{}\": {}` (before was `{}`)",
-                                    source_key,
-                                    old_value,
-                                    source_value
-                                );
-                            }
+                                source_key,
+                                old_value,
+                                source_value
+                            );
                         }
                     }
                     _ => {
@@ -1168,35 +1166,31 @@ impl SettingsStore {
             if let Some(release_settings) = &self
                 .raw_user_settings
                 .get(release_channel::RELEASE_CHANNEL.dev_name())
-            {
-                if let Some(release_settings) = setting_value
+                && let Some(release_settings) = setting_value
                     .deserialize_setting(release_settings)
                     .log_err()
-                {
-                    release_channel_settings = Some(release_settings);
-                }
+            {
+                release_channel_settings = Some(release_settings);
             }
 
             let mut os_settings = None;
-            if let Some(settings) = &self.raw_user_settings.get(env::consts::OS) {
-                if let Some(settings) = setting_value.deserialize_setting(settings).log_err() {
-                    os_settings = Some(settings);
-                }
+            if let Some(settings) = &self.raw_user_settings.get(env::consts::OS)
+                && let Some(settings) = setting_value.deserialize_setting(settings).log_err()
+            {
+                os_settings = Some(settings);
             }
 
             let mut profile_settings = None;
-            if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() {
-                if let Some(profiles) = self.raw_user_settings.get("profiles") {
-                    if let Some(profile_json) = profiles.get(&active_profile.0) {
-                        profile_settings =
-                            setting_value.deserialize_setting(profile_json).log_err();
-                    }
-                }
+            if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>()
+                && let Some(profiles) = self.raw_user_settings.get("profiles")
+                && let Some(profile_json) = profiles.get(&active_profile.0)
+            {
+                profile_settings = setting_value.deserialize_setting(profile_json).log_err();
             }
 
             // If the global settings file changed, reload the global value for the field.
-            if changed_local_path.is_none() {
-                if let Some(value) = setting_value
+            if changed_local_path.is_none()
+                && let Some(value) = setting_value
                     .load_setting(
                         SettingsSources {
                             default: &default_settings,
@@ -1212,9 +1206,8 @@ impl SettingsStore {
                         cx,
                     )
                     .log_err()
-                {
-                    setting_value.set_global_value(value);
-                }
+            {
+                setting_value.set_global_value(value);
             }
 
             // Reload the local values for the setting.
@@ -1223,12 +1216,12 @@ impl SettingsStore {
             for ((root_id, directory_path), local_settings) in &self.raw_local_settings {
                 // Build a stack of all of the local values for that setting.
                 while let Some(prev_entry) = paths_stack.last() {
-                    if let Some((prev_root_id, prev_path)) = prev_entry {
-                        if root_id != prev_root_id || !directory_path.starts_with(prev_path) {
-                            paths_stack.pop();
-                            project_settings_stack.pop();
-                            continue;
-                        }
+                    if let Some((prev_root_id, prev_path)) = prev_entry
+                        && (root_id != prev_root_id || !directory_path.starts_with(prev_path))
+                    {
+                        paths_stack.pop();
+                        project_settings_stack.pop();
+                        continue;
                     }
                     break;
                 }

crates/snippets_ui/src/snippets_ui.rs πŸ”—

@@ -163,13 +163,12 @@ impl ScopeSelectorDelegate {
             for entry in read_dir {
                 if let Some(entry) = entry.log_err() {
                     let path = entry.path();
-                    if let (Some(stem), Some(extension)) = (path.file_stem(), path.extension()) {
-                        if extension.to_os_string().to_str() == Some("json") {
-                            if let Ok(file_name) = stem.to_os_string().into_string() {
-                                existing_scopes
-                                    .insert(ScopeName::from(ScopeFileName(Cow::Owned(file_name))));
-                            }
-                        }
+                    if let (Some(stem), Some(extension)) = (path.file_stem(), path.extension())
+                        && extension.to_os_string().to_str() == Some("json")
+                        && let Ok(file_name) = stem.to_os_string().into_string()
+                    {
+                        existing_scopes
+                            .insert(ScopeName::from(ScopeFileName(Cow::Owned(file_name))));
                     }
                 }
             }

crates/sqlez/src/connection.rs πŸ”—

@@ -213,38 +213,37 @@ impl Connection {
 
 fn parse_alter_table(remaining_sql_str: &str) -> Option<(String, String)> {
     let remaining_sql_str = remaining_sql_str.to_lowercase();
-    if remaining_sql_str.starts_with("alter") {
-        if let Some(table_offset) = remaining_sql_str.find("table") {
-            let after_table_offset = table_offset + "table".len();
-            let table_to_alter = remaining_sql_str
-                .chars()
-                .skip(after_table_offset)
-                .skip_while(|c| c.is_whitespace())
-                .take_while(|c| !c.is_whitespace())
-                .collect::<String>();
-            if !table_to_alter.is_empty() {
-                let column_name =
-                    if let Some(rename_offset) = remaining_sql_str.find("rename column") {
-                        let after_rename_offset = rename_offset + "rename column".len();
-                        remaining_sql_str
-                            .chars()
-                            .skip(after_rename_offset)
-                            .skip_while(|c| c.is_whitespace())
-                            .take_while(|c| !c.is_whitespace())
-                            .collect::<String>()
-                    } else if let Some(drop_offset) = remaining_sql_str.find("drop column") {
-                        let after_drop_offset = drop_offset + "drop column".len();
-                        remaining_sql_str
-                            .chars()
-                            .skip(after_drop_offset)
-                            .skip_while(|c| c.is_whitespace())
-                            .take_while(|c| !c.is_whitespace())
-                            .collect::<String>()
-                    } else {
-                        "__place_holder_column_for_syntax_checking".to_string()
-                    };
-                return Some((table_to_alter, column_name));
-            }
+    if remaining_sql_str.starts_with("alter")
+        && let Some(table_offset) = remaining_sql_str.find("table")
+    {
+        let after_table_offset = table_offset + "table".len();
+        let table_to_alter = remaining_sql_str
+            .chars()
+            .skip(after_table_offset)
+            .skip_while(|c| c.is_whitespace())
+            .take_while(|c| !c.is_whitespace())
+            .collect::<String>();
+        if !table_to_alter.is_empty() {
+            let column_name = if let Some(rename_offset) = remaining_sql_str.find("rename column") {
+                let after_rename_offset = rename_offset + "rename column".len();
+                remaining_sql_str
+                    .chars()
+                    .skip(after_rename_offset)
+                    .skip_while(|c| c.is_whitespace())
+                    .take_while(|c| !c.is_whitespace())
+                    .collect::<String>()
+            } else if let Some(drop_offset) = remaining_sql_str.find("drop column") {
+                let after_drop_offset = drop_offset + "drop column".len();
+                remaining_sql_str
+                    .chars()
+                    .skip(after_drop_offset)
+                    .skip_while(|c| c.is_whitespace())
+                    .take_while(|c| !c.is_whitespace())
+                    .collect::<String>()
+            } else {
+                "__place_holder_column_for_syntax_checking".to_string()
+            };
+            return Some((table_to_alter, column_name));
         }
     }
     None

crates/sum_tree/src/cursor.rs πŸ”—

@@ -530,10 +530,10 @@ where
         debug_assert!(self.stack.is_empty() || self.stack.last().unwrap().tree.0.is_leaf());
 
         let mut end = self.position.clone();
-        if bias == Bias::Left {
-            if let Some(summary) = self.item_summary() {
-                end.add_summary(summary, self.cx);
-            }
+        if bias == Bias::Left
+            && let Some(summary) = self.item_summary()
+        {
+            end.add_summary(summary, self.cx);
         }
 
         target.cmp(&end, self.cx) == Ordering::Equal

crates/sum_tree/src/sum_tree.rs πŸ”—

@@ -674,11 +674,11 @@ impl<T: KeyedItem> SumTree<T> {
         *self = {
             let mut cursor = self.cursor::<T::Key>(cx);
             let mut new_tree = cursor.slice(&item.key(), Bias::Left);
-            if let Some(cursor_item) = cursor.item() {
-                if cursor_item.key() == item.key() {
-                    replaced = Some(cursor_item.clone());
-                    cursor.next();
-                }
+            if let Some(cursor_item) = cursor.item()
+                && cursor_item.key() == item.key()
+            {
+                replaced = Some(cursor_item.clone());
+                cursor.next();
             }
             new_tree.push(item, cx);
             new_tree.append(cursor.suffix(), cx);
@@ -692,11 +692,11 @@ impl<T: KeyedItem> SumTree<T> {
         *self = {
             let mut cursor = self.cursor::<T::Key>(cx);
             let mut new_tree = cursor.slice(key, Bias::Left);
-            if let Some(item) = cursor.item() {
-                if item.key() == *key {
-                    removed = Some(item.clone());
-                    cursor.next();
-                }
+            if let Some(item) = cursor.item()
+                && item.key() == *key
+            {
+                removed = Some(item.clone());
+                cursor.next();
             }
             new_tree.append(cursor.suffix(), cx);
             new_tree
@@ -736,11 +736,11 @@ impl<T: KeyedItem> SumTree<T> {
                     old_item = cursor.item();
                 }
 
-                if let Some(old_item) = old_item {
-                    if old_item.key() == new_key {
-                        removed.push(old_item.clone());
-                        cursor.next();
-                    }
+                if let Some(old_item) = old_item
+                    && old_item.key() == new_key
+                {
+                    removed.push(old_item.clone());
+                    cursor.next();
                 }
 
                 match edit {

crates/svg_preview/src/svg_preview_view.rs πŸ”—

@@ -32,79 +32,74 @@ pub enum SvgPreviewMode {
 impl SvgPreviewView {
     pub fn register(workspace: &mut Workspace, _window: &mut Window, _cx: &mut Context<Workspace>) {
         workspace.register_action(move |workspace, _: &OpenPreview, window, cx| {
-            if let Some(editor) = Self::resolve_active_item_as_svg_editor(workspace, cx) {
-                if Self::is_svg_file(&editor, cx) {
-                    let view = Self::create_svg_view(
-                        SvgPreviewMode::Default,
-                        workspace,
-                        editor.clone(),
-                        window,
-                        cx,
-                    );
-                    workspace.active_pane().update(cx, |pane, cx| {
-                        if let Some(existing_view_idx) =
-                            Self::find_existing_preview_item_idx(pane, &editor, cx)
-                        {
-                            pane.activate_item(existing_view_idx, true, true, window, cx);
-                        } else {
-                            pane.add_item(Box::new(view), true, true, None, window, cx)
-                        }
-                    });
-                    cx.notify();
-                }
+            if let Some(editor) = Self::resolve_active_item_as_svg_editor(workspace, cx)
+                && Self::is_svg_file(&editor, cx)
+            {
+                let view = Self::create_svg_view(
+                    SvgPreviewMode::Default,
+                    workspace,
+                    editor.clone(),
+                    window,
+                    cx,
+                );
+                workspace.active_pane().update(cx, |pane, cx| {
+                    if let Some(existing_view_idx) =
+                        Self::find_existing_preview_item_idx(pane, &editor, cx)
+                    {
+                        pane.activate_item(existing_view_idx, true, true, window, cx);
+                    } else {
+                        pane.add_item(Box::new(view), true, true, None, window, cx)
+                    }
+                });
+                cx.notify();
             }
         });
 
         workspace.register_action(move |workspace, _: &OpenPreviewToTheSide, window, cx| {
-            if let Some(editor) = Self::resolve_active_item_as_svg_editor(workspace, cx) {
-                if Self::is_svg_file(&editor, cx) {
-                    let editor_clone = editor.clone();
-                    let view = Self::create_svg_view(
-                        SvgPreviewMode::Default,
-                        workspace,
-                        editor_clone,
-                        window,
-                        cx,
-                    );
-                    let pane = workspace
-                        .find_pane_in_direction(workspace::SplitDirection::Right, cx)
-                        .unwrap_or_else(|| {
-                            workspace.split_pane(
-                                workspace.active_pane().clone(),
-                                workspace::SplitDirection::Right,
-                                window,
-                                cx,
-                            )
-                        });
-                    pane.update(cx, |pane, cx| {
-                        if let Some(existing_view_idx) =
-                            Self::find_existing_preview_item_idx(pane, &editor, cx)
-                        {
-                            pane.activate_item(existing_view_idx, true, true, window, cx);
-                        } else {
-                            pane.add_item(Box::new(view), false, false, None, window, cx)
-                        }
+            if let Some(editor) = Self::resolve_active_item_as_svg_editor(workspace, cx)
+                && Self::is_svg_file(&editor, cx)
+            {
+                let editor_clone = editor.clone();
+                let view = Self::create_svg_view(
+                    SvgPreviewMode::Default,
+                    workspace,
+                    editor_clone,
+                    window,
+                    cx,
+                );
+                let pane = workspace
+                    .find_pane_in_direction(workspace::SplitDirection::Right, cx)
+                    .unwrap_or_else(|| {
+                        workspace.split_pane(
+                            workspace.active_pane().clone(),
+                            workspace::SplitDirection::Right,
+                            window,
+                            cx,
+                        )
                     });
-                    cx.notify();
-                }
+                pane.update(cx, |pane, cx| {
+                    if let Some(existing_view_idx) =
+                        Self::find_existing_preview_item_idx(pane, &editor, cx)
+                    {
+                        pane.activate_item(existing_view_idx, true, true, window, cx);
+                    } else {
+                        pane.add_item(Box::new(view), false, false, None, window, cx)
+                    }
+                });
+                cx.notify();
             }
         });
 
         workspace.register_action(move |workspace, _: &OpenFollowingPreview, window, cx| {
-            if let Some(editor) = Self::resolve_active_item_as_svg_editor(workspace, cx) {
-                if Self::is_svg_file(&editor, cx) {
-                    let view = Self::create_svg_view(
-                        SvgPreviewMode::Follow,
-                        workspace,
-                        editor,
-                        window,
-                        cx,
-                    );
-                    workspace.active_pane().update(cx, |pane, cx| {
-                        pane.add_item(Box::new(view), true, true, None, window, cx)
-                    });
-                    cx.notify();
-                }
+            if let Some(editor) = Self::resolve_active_item_as_svg_editor(workspace, cx)
+                && Self::is_svg_file(&editor, cx)
+            {
+                let view =
+                    Self::create_svg_view(SvgPreviewMode::Follow, workspace, editor, window, cx);
+                workspace.active_pane().update(cx, |pane, cx| {
+                    pane.add_item(Box::new(view), true, true, None, window, cx)
+                });
+                cx.notify();
             }
         });
     }
@@ -192,18 +187,15 @@ impl SvgPreviewView {
                             match event {
                                 workspace::Event::ActiveItemChanged => {
                                     let workspace_read = workspace.read(cx);
-                                    if let Some(active_item) = workspace_read.active_item(cx) {
-                                        if let Some(editor_entity) =
+                                    if let Some(active_item) = workspace_read.active_item(cx)
+                                        && let Some(editor_entity) =
                                             active_item.downcast::<Editor>()
-                                        {
-                                            if Self::is_svg_file(&editor_entity, cx) {
-                                                let new_path =
-                                                    Self::get_svg_path(&editor_entity, cx);
-                                                if this.svg_path != new_path {
-                                                    this.svg_path = new_path;
-                                                    cx.notify();
-                                                }
-                                            }
+                                        && Self::is_svg_file(&editor_entity, cx)
+                                    {
+                                        let new_path = Self::get_svg_path(&editor_entity, cx);
+                                        if this.svg_path != new_path {
+                                            this.svg_path = new_path;
+                                            cx.notify();
                                         }
                                     }
                                 }
@@ -232,15 +224,15 @@ impl SvgPreviewView {
     {
         let app = cx.borrow();
         let buffer = editor.read(app).buffer().read(app);
-        if let Some(buffer) = buffer.as_singleton() {
-            if let Some(file) = buffer.read(app).file() {
-                return file
-                    .path()
-                    .extension()
-                    .and_then(|ext| ext.to_str())
-                    .map(|ext| ext.eq_ignore_ascii_case("svg"))
-                    .unwrap_or(false);
-            }
+        if let Some(buffer) = buffer.as_singleton()
+            && let Some(file) = buffer.read(app).file()
+        {
+            return file
+                .path()
+                .extension()
+                .and_then(|ext| ext.to_str())
+                .map(|ext| ext.eq_ignore_ascii_case("svg"))
+                .unwrap_or(false);
         }
         false
     }

crates/task/src/debug_format.rs πŸ”—

@@ -299,13 +299,12 @@ impl DebugTaskFile {
             if let Some(properties) = template_object
                 .get_mut("properties")
                 .and_then(|value| value.as_object_mut())
+                && properties.remove("label").is_none()
             {
-                if properties.remove("label").is_none() {
-                    debug_panic!(
-                        "Generated TaskTemplate json schema did not have expected 'label' field. \
+                debug_panic!(
+                    "Generated TaskTemplate json schema did not have expected 'label' field. \
                         Schema of 2nd alternative is: {template_object:?}"
-                    );
-                }
+                );
             }
 
             if let Some(arr) = template_object

crates/task/src/vscode_debug_format.rs πŸ”—

@@ -30,12 +30,12 @@ impl VsCodeDebugTaskDefinition {
         let label = replacer.replace(&self.name);
         let mut config = replacer.replace_value(self.other_attributes);
         let adapter = task_type_to_adapter_name(&self.r#type);
-        if let Some(config) = config.as_object_mut() {
-            if adapter == "JavaScript" {
-                config.insert("type".to_owned(), self.r#type.clone().into());
-                if let Some(port) = self.port.take() {
-                    config.insert("port".to_owned(), port.into());
-                }
+        if let Some(config) = config.as_object_mut()
+            && adapter == "JavaScript"
+        {
+            config.insert("type".to_owned(), self.r#type.clone().into());
+            if let Some(port) = self.port.take() {
+                config.insert("port".to_owned(), port.into());
             }
         }
         let definition = DebugScenario {

crates/tasks_ui/src/tasks_ui.rs πŸ”—

@@ -227,10 +227,10 @@ where
 
                 tasks.retain_mut(|(task_source_kind, target_task)| {
                     if predicate((task_source_kind, target_task)) {
-                        if let Some(overrides) = &overrides {
-                            if let Some(target_override) = overrides.reveal_target {
-                                target_task.reveal_target = target_override;
-                            }
+                        if let Some(overrides) = &overrides
+                            && let Some(target_override) = overrides.reveal_target
+                        {
+                            target_task.reveal_target = target_override;
                         }
                         workspace.schedule_task(
                             task_source_kind.clone(),
@@ -343,11 +343,10 @@ pub fn task_contexts(
         task_contexts.lsp_task_sources = lsp_task_sources;
         task_contexts.latest_selection = latest_selection;
 
-        if let Some(editor_context_task) = editor_context_task {
-            if let Some(editor_context) = editor_context_task.await {
-                task_contexts.active_item_context =
-                    Some((active_worktree, location, editor_context));
-            }
+        if let Some(editor_context_task) = editor_context_task
+            && let Some(editor_context) = editor_context_task.await
+        {
+            task_contexts.active_item_context = Some((active_worktree, location, editor_context));
         }
 
         if let Some(active_worktree) = active_worktree {

crates/terminal/src/terminal.rs πŸ”—

@@ -1051,15 +1051,16 @@ impl Terminal {
         navigation_target: MaybeNavigationTarget,
         cx: &mut Context<Self>,
     ) {
-        if let Some(prev_word) = prev_word {
-            if prev_word.word == word && prev_word.word_match == word_match {
-                self.last_content.last_hovered_word = Some(HoveredWord {
-                    word,
-                    word_match,
-                    id: prev_word.id,
-                });
-                return;
-            }
+        if let Some(prev_word) = prev_word
+            && prev_word.word == word
+            && prev_word.word_match == word_match
+        {
+            self.last_content.last_hovered_word = Some(HoveredWord {
+                word,
+                word_match,
+                id: prev_word.id,
+            });
+            return;
         }
 
         self.last_content.last_hovered_word = Some(HoveredWord {
@@ -1517,12 +1518,11 @@ impl Terminal {
                 self.last_content.display_offset,
             );
 
-            if self.mouse_changed(point, side) {
-                if let Some(bytes) =
+            if self.mouse_changed(point, side)
+                && let Some(bytes) =
                     mouse_moved_report(point, e.pressed_button, e.modifiers, self.last_content.mode)
-                {
-                    self.pty_tx.notify(bytes);
-                }
+            {
+                self.pty_tx.notify(bytes);
             }
         } else if e.modifiers.secondary() {
             self.word_from_position(e.position);
@@ -1864,10 +1864,10 @@ impl Terminal {
     }
 
     pub fn kill_active_task(&mut self) {
-        if let Some(task) = self.task() {
-            if task.status == TaskStatus::Running {
-                self.pty_info.kill_current_process();
-            }
+        if let Some(task) = self.task()
+            && task.status == TaskStatus::Running
+        {
+            self.pty_info.kill_current_process();
         }
     }
 

crates/terminal/src/terminal_settings.rs πŸ”—

@@ -325,10 +325,10 @@ impl settings::Settings for TerminalSettings {
             .and_then(|v| v.as_object())
         {
             for (k, v) in env {
-                if v.is_null() {
-                    if let Some(zed_env) = current.env.as_mut() {
-                        zed_env.remove(k);
-                    }
+                if v.is_null()
+                    && let Some(zed_env) = current.env.as_mut()
+                {
+                    zed_env.remove(k);
                 }
                 let Some(v) = v.as_str() else { continue };
                 if let Some(zed_env) = current.env.as_mut() {

crates/terminal_view/src/terminal_element.rs πŸ”—

@@ -583,15 +583,15 @@ impl TerminalElement {
             strikethrough,
         };
 
-        if let Some((style, range)) = hyperlink {
-            if range.contains(&indexed.point) {
-                if let Some(underline) = style.underline {
-                    result.underline = Some(underline);
-                }
+        if let Some((style, range)) = hyperlink
+            && range.contains(&indexed.point)
+        {
+            if let Some(underline) = style.underline {
+                result.underline = Some(underline);
+            }
 
-                if let Some(color) = style.color {
-                    result.color = color;
-                }
+            if let Some(color) = style.color {
+                result.color = color;
             }
         }
 
@@ -1275,9 +1275,9 @@ impl Element for TerminalElement {
                     }
                     let text_paint_time = text_paint_start.elapsed();
 
-                    if let Some(text_to_mark) = &marked_text_cloned {
-                        if !text_to_mark.is_empty() {
-                            if let Some(cursor_layout) = &original_cursor {
+                    if let Some(text_to_mark) = &marked_text_cloned
+                        && !text_to_mark.is_empty()
+                            && let Some(cursor_layout) = &original_cursor {
                                 let ime_position = cursor_layout.bounding_rect(origin).origin;
                                 let mut ime_style = layout.base_text_style.clone();
                                 ime_style.underline = Some(UnderlineStyle {
@@ -1303,14 +1303,11 @@ impl Element for TerminalElement {
                                     .paint(ime_position, layout.dimensions.line_height, window, cx)
                                     .log_err();
                             }
-                        }
-                    }
 
-                    if self.cursor_visible && marked_text_cloned.is_none() {
-                        if let Some(mut cursor) = original_cursor {
+                    if self.cursor_visible && marked_text_cloned.is_none()
+                        && let Some(mut cursor) = original_cursor {
                             cursor.paint(origin, window, cx);
                         }
-                    }
 
                     if let Some(mut element) = block_below_cursor_element {
                         element.paint(window, cx);

crates/terminal_view/src/terminal_panel.rs πŸ”—

@@ -255,8 +255,7 @@ impl TerminalPanel {
                     .transpose()
                     .log_err()
                     .flatten()
-                {
-                    if let Ok(serialized) = workspace
+                    && let Ok(serialized) = workspace
                         .update_in(&mut cx, |workspace, window, cx| {
                             deserialize_terminal_panel(
                                 workspace.weak_handle(),
@@ -268,9 +267,8 @@ impl TerminalPanel {
                             )
                         })?
                         .await
-                    {
-                        terminal_panel = Some(serialized);
-                    }
+                {
+                    terminal_panel = Some(serialized);
                 }
             }
             _ => {}
@@ -1077,11 +1075,10 @@ pub fn new_terminal_pane(
                                 return ControlFlow::Break(());
                             }
                         };
-                    } else if let Some(project_path) = item.project_path(cx) {
-                        if let Some(entry_path) = project.read(cx).absolute_path(&project_path, cx)
-                        {
-                            add_paths_to_terminal(pane, &[entry_path], window, cx);
-                        }
+                    } else if let Some(project_path) = item.project_path(cx)
+                        && let Some(entry_path) = project.read(cx).absolute_path(&project_path, cx)
+                    {
+                        add_paths_to_terminal(pane, &[entry_path], window, cx);
                     }
                 }
             } else if let Some(selection) = dropped_item.downcast_ref::<DraggedSelection>() {
@@ -1103,10 +1100,8 @@ pub fn new_terminal_pane(
                 {
                     add_paths_to_terminal(pane, &[entry_path], window, cx);
                 }
-            } else if is_local {
-                if let Some(paths) = dropped_item.downcast_ref::<ExternalPaths>() {
-                    add_paths_to_terminal(pane, paths.paths(), window, cx);
-                }
+            } else if is_local && let Some(paths) = dropped_item.downcast_ref::<ExternalPaths>() {
+                add_paths_to_terminal(pane, paths.paths(), window, cx);
             }
 
             ControlFlow::Break(())

crates/terminal_view/src/terminal_view.rs πŸ”—

@@ -308,10 +308,10 @@ impl TerminalView {
                 } else {
                     let mut displayed_lines = total_lines;
 
-                    if !self.focus_handle.is_focused(window) {
-                        if let Some(max_lines) = max_lines_when_unfocused {
-                            displayed_lines = displayed_lines.min(*max_lines)
-                        }
+                    if !self.focus_handle.is_focused(window)
+                        && let Some(max_lines) = max_lines_when_unfocused
+                    {
+                        displayed_lines = displayed_lines.min(*max_lines)
                     }
 
                     ContentMode::Inline {
@@ -1156,26 +1156,26 @@ fn subscribe_for_terminal_events(
 
                                 if let Some(opened_item) = opened_items.first() {
                                     if open_target.is_file() {
-                                        if let Some(Ok(opened_item)) = opened_item {
-                                            if let Some(row) = path_to_open.row {
-                                                let col = path_to_open.column.unwrap_or(0);
-                                                if let Some(active_editor) =
-                                                    opened_item.downcast::<Editor>()
-                                                {
-                                                    active_editor
-                                                        .downgrade()
-                                                        .update_in(cx, |editor, window, cx| {
-                                                            editor.go_to_singleton_buffer_point(
-                                                                language::Point::new(
-                                                                    row.saturating_sub(1),
-                                                                    col.saturating_sub(1),
-                                                                ),
-                                                                window,
-                                                                cx,
-                                                            )
-                                                        })
-                                                        .log_err();
-                                                }
+                                        if let Some(Ok(opened_item)) = opened_item
+                                            && let Some(row) = path_to_open.row
+                                        {
+                                            let col = path_to_open.column.unwrap_or(0);
+                                            if let Some(active_editor) =
+                                                opened_item.downcast::<Editor>()
+                                            {
+                                                active_editor
+                                                    .downgrade()
+                                                    .update_in(cx, |editor, window, cx| {
+                                                        editor.go_to_singleton_buffer_point(
+                                                            language::Point::new(
+                                                                row.saturating_sub(1),
+                                                                col.saturating_sub(1),
+                                                            ),
+                                                            window,
+                                                            cx,
+                                                        )
+                                                    })
+                                                    .log_err();
                                             }
                                         }
                                     } else if open_target.is_dir() {
@@ -1321,17 +1321,17 @@ fn possible_open_target(
                 }
             };
 
-            if path_to_check.path.is_relative() {
-                if let Some(entry) = worktree.read(cx).entry_for_path(&path_to_check.path) {
-                    return Task::ready(Some(OpenTarget::Worktree(
-                        PathWithPosition {
-                            path: worktree_root.join(&entry.path),
-                            row: path_to_check.row,
-                            column: path_to_check.column,
-                        },
-                        entry.clone(),
-                    )));
-                }
+            if path_to_check.path.is_relative()
+                && let Some(entry) = worktree.read(cx).entry_for_path(&path_to_check.path)
+            {
+                return Task::ready(Some(OpenTarget::Worktree(
+                    PathWithPosition {
+                        path: worktree_root.join(&entry.path),
+                        row: path_to_check.row,
+                        column: path_to_check.column,
+                    },
+                    entry.clone(),
+                )));
             }
 
             paths_to_check.push(path_to_check);
@@ -1428,11 +1428,11 @@ fn possible_open_target(
     let fs = workspace.read(cx).project().read(cx).fs().clone();
     cx.background_spawn(async move {
         for mut path_to_check in fs_paths_to_check {
-            if let Some(fs_path_to_check) = fs.canonicalize(&path_to_check.path).await.ok() {
-                if let Some(metadata) = fs.metadata(&fs_path_to_check).await.ok().flatten() {
-                    path_to_check.path = fs_path_to_check;
-                    return Some(OpenTarget::File(path_to_check, metadata));
-                }
+            if let Some(fs_path_to_check) = fs.canonicalize(&path_to_check.path).await.ok()
+                && let Some(metadata) = fs.metadata(&fs_path_to_check).await.ok().flatten()
+            {
+                path_to_check.path = fs_path_to_check;
+                return Some(OpenTarget::File(path_to_check, metadata));
             }
         }
 

crates/text/src/text.rs πŸ”—

@@ -446,10 +446,10 @@ impl History {
     }
 
     fn merge_transactions(&mut self, transaction: TransactionId, destination: TransactionId) {
-        if let Some(transaction) = self.forget(transaction) {
-            if let Some(destination) = self.transaction_mut(destination) {
-                destination.edit_ids.extend(transaction.edit_ids);
-            }
+        if let Some(transaction) = self.forget(transaction)
+            && let Some(destination) = self.transaction_mut(destination)
+        {
+            destination.edit_ids.extend(transaction.edit_ids);
         }
     }
 
@@ -1585,11 +1585,11 @@ impl Buffer {
             .map(Some)
             .chain([None])
             .filter_map(move |range| {
-                if let Some((range, prev_range)) = range.as_ref().zip(prev_range.as_mut()) {
-                    if prev_range.end == range.start {
-                        prev_range.end = range.end;
-                        return None;
-                    }
+                if let Some((range, prev_range)) = range.as_ref().zip(prev_range.as_mut())
+                    && prev_range.end == range.start
+                {
+                    prev_range.end = range.end;
+                    return None;
                 }
                 let result = prev_range.clone();
                 prev_range = range;
@@ -1685,10 +1685,10 @@ impl Buffer {
             rx = Some(channel.1);
         }
         async move {
-            if let Some(mut rx) = rx {
-                if rx.recv().await.is_none() {
-                    anyhow::bail!("gave up waiting for version");
-                }
+            if let Some(mut rx) = rx
+                && rx.recv().await.is_none()
+            {
+                anyhow::bail!("gave up waiting for version");
             }
             Ok(())
         }

crates/theme/src/fallback_themes.rs πŸ”—

@@ -34,10 +34,10 @@ pub(crate) fn apply_status_color_defaults(status: &mut StatusColorsRefinement) {
         (&status.error, &mut status.error_background),
         (&status.hidden, &mut status.hidden_background),
     ] {
-        if bg_color.is_none() {
-            if let Some(fg_color) = fg_color {
-                *bg_color = Some(fg_color.opacity(0.25));
-            }
+        if bg_color.is_none()
+            && let Some(fg_color) = fg_color
+        {
+            *bg_color = Some(fg_color.opacity(0.25));
         }
     }
 }

crates/title_bar/src/application_menu.rs πŸ”—

@@ -269,32 +269,31 @@ impl Render for ApplicationMenu {
     fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
         let all_menus_shown = self.all_menus_shown(cx);
 
-        if let Some(pending_menu_open) = self.pending_menu_open.take() {
-            if let Some(entry) = self
+        if let Some(pending_menu_open) = self.pending_menu_open.take()
+            && let Some(entry) = self
                 .entries
                 .iter()
                 .find(|entry| entry.menu.name == pending_menu_open && !entry.handle.is_deployed())
-            {
-                let handle_to_show = entry.handle.clone();
-                let handles_to_hide: Vec<_> = self
-                    .entries
-                    .iter()
-                    .filter(|e| e.menu.name != pending_menu_open && e.handle.is_deployed())
-                    .map(|e| e.handle.clone())
-                    .collect();
-
-                if handles_to_hide.is_empty() {
-                    // We need to wait for the next frame to show all menus first,
-                    // before we can handle show/hide operations
-                    window.on_next_frame(move |window, cx| {
-                        handles_to_hide.iter().for_each(|handle| handle.hide(cx));
-                        window.defer(cx, move |window, cx| handle_to_show.show(window, cx));
-                    });
-                } else {
-                    // Since menus are already shown, we can directly handle show/hide operations
+        {
+            let handle_to_show = entry.handle.clone();
+            let handles_to_hide: Vec<_> = self
+                .entries
+                .iter()
+                .filter(|e| e.menu.name != pending_menu_open && e.handle.is_deployed())
+                .map(|e| e.handle.clone())
+                .collect();
+
+            if handles_to_hide.is_empty() {
+                // We need to wait for the next frame to show all menus first,
+                // before we can handle show/hide operations
+                window.on_next_frame(move |window, cx| {
                     handles_to_hide.iter().for_each(|handle| handle.hide(cx));
-                    cx.defer_in(window, move |_, window, cx| handle_to_show.show(window, cx));
-                }
+                    window.defer(cx, move |window, cx| handle_to_show.show(window, cx));
+                });
+            } else {
+                // Since menus are already shown, we can directly handle show/hide operations
+                handles_to_hide.iter().for_each(|handle| handle.hide(cx));
+                cx.defer_in(window, move |_, window, cx| handle_to_show.show(window, cx));
             }
         }
 

crates/title_bar/src/title_bar.rs πŸ”—

@@ -593,11 +593,11 @@ impl TitleBar {
                     Button::new("connection-status", label)
                         .label_size(LabelSize::Small)
                         .on_click(|_, window, cx| {
-                            if let Some(auto_updater) = auto_update::AutoUpdater::get(cx) {
-                                if auto_updater.read(cx).status().is_updated() {
-                                    workspace::reload(cx);
-                                    return;
-                                }
+                            if let Some(auto_updater) = auto_update::AutoUpdater::get(cx)
+                                && auto_updater.read(cx).status().is_updated()
+                            {
+                                workspace::reload(cx);
+                                return;
                             }
                             auto_update::check(&Default::default(), window, cx);
                         })

crates/toolchain_selector/src/active_toolchain.rs πŸ”—

@@ -121,31 +121,30 @@ impl ActiveToolchain {
         cx: &mut Context<Self>,
     ) {
         let editor = editor.read(cx);
-        if let Some((_, buffer, _)) = editor.active_excerpt(cx) {
-            if let Some(worktree_id) = buffer.read(cx).file().map(|file| file.worktree_id(cx)) {
-                if self
-                    .active_buffer
-                    .as_ref()
-                    .is_some_and(|(old_worktree_id, old_buffer, _)| {
-                        (old_worktree_id, old_buffer.entity_id())
-                            == (&worktree_id, buffer.entity_id())
-                    })
-                {
-                    return;
-                }
-
-                let subscription = cx.subscribe_in(
-                    &buffer,
-                    window,
-                    |this, _, event: &BufferEvent, window, cx| {
-                        if matches!(event, BufferEvent::LanguageChanged) {
-                            this._update_toolchain_task = Self::spawn_tracker_task(window, cx);
-                        }
-                    },
-                );
-                self.active_buffer = Some((worktree_id, buffer.downgrade(), subscription));
-                self._update_toolchain_task = Self::spawn_tracker_task(window, cx);
+        if let Some((_, buffer, _)) = editor.active_excerpt(cx)
+            && let Some(worktree_id) = buffer.read(cx).file().map(|file| file.worktree_id(cx))
+        {
+            if self
+                .active_buffer
+                .as_ref()
+                .is_some_and(|(old_worktree_id, old_buffer, _)| {
+                    (old_worktree_id, old_buffer.entity_id()) == (&worktree_id, buffer.entity_id())
+                })
+            {
+                return;
             }
+
+            let subscription = cx.subscribe_in(
+                &buffer,
+                window,
+                |this, _, event: &BufferEvent, window, cx| {
+                    if matches!(event, BufferEvent::LanguageChanged) {
+                        this._update_toolchain_task = Self::spawn_tracker_task(window, cx);
+                    }
+                },
+            );
+            self.active_buffer = Some((worktree_id, buffer.downgrade(), subscription));
+            self._update_toolchain_task = Self::spawn_tracker_task(window, cx);
         }
 
         cx.notify();

crates/toolchain_selector/src/toolchain_selector.rs πŸ”—

@@ -211,16 +211,15 @@ impl ToolchainSelectorDelegate {
                 let _ = this.update_in(cx, move |this, window, cx| {
                     this.delegate.candidates = available_toolchains;
 
-                    if let Some(active_toolchain) = active_toolchain {
-                        if let Some(position) = this
+                    if let Some(active_toolchain) = active_toolchain
+                        && let Some(position) = this
                             .delegate
                             .candidates
                             .toolchains
                             .iter()
                             .position(|toolchain| *toolchain == active_toolchain)
-                        {
-                            this.delegate.set_selected_index(position, window, cx);
-                        }
+                    {
+                        this.delegate.set_selected_index(position, window, cx);
                     }
                     this.update_matches(this.query(cx), window, cx);
                 });

crates/ui/src/components/label/highlighted_label.rs πŸ”—

@@ -98,12 +98,12 @@ pub fn highlight_ranges(
 
         loop {
             end_ix = end_ix + text[end_ix..].chars().next().unwrap().len_utf8();
-            if let Some(&next_ix) = highlight_indices.peek() {
-                if next_ix == end_ix {
-                    end_ix = next_ix;
-                    highlight_indices.next();
-                    continue;
-                }
+            if let Some(&next_ix) = highlight_indices.peek()
+                && next_ix == end_ix
+            {
+                end_ix = next_ix;
+                highlight_indices.next();
+                continue;
             }
             break;
         }

crates/ui/src/components/popover_menu.rs πŸ”—

@@ -72,10 +72,10 @@ impl<M: ManagedView> PopoverMenuHandle<M> {
     }
 
     pub fn hide(&self, cx: &mut App) {
-        if let Some(state) = self.0.borrow().as_ref() {
-            if let Some(menu) = state.menu.borrow().as_ref() {
-                menu.update(cx, |_, cx| cx.emit(DismissEvent));
-            }
+        if let Some(state) = self.0.borrow().as_ref()
+            && let Some(menu) = state.menu.borrow().as_ref()
+        {
+            menu.update(cx, |_, cx| cx.emit(DismissEvent));
         }
     }
 
@@ -278,10 +278,10 @@ fn show_menu<M: ManagedView>(
 
     window
         .subscribe(&new_menu, cx, move |modal, _: &DismissEvent, window, cx| {
-            if modal.focus_handle(cx).contains_focused(window, cx) {
-                if let Some(previous_focus_handle) = previous_focus_handle.as_ref() {
-                    window.focus(previous_focus_handle);
-                }
+            if modal.focus_handle(cx).contains_focused(window, cx)
+                && let Some(previous_focus_handle) = previous_focus_handle.as_ref()
+            {
+                window.focus(previous_focus_handle);
             }
             *menu2.borrow_mut() = None;
             window.refresh();
@@ -373,14 +373,14 @@ impl<M: ManagedView> Element for PopoverMenu<M> {
                     (child_builder)(element_state.menu.clone(), self.menu_builder.clone())
                 });
 
-                if let Some(trigger_handle) = self.trigger_handle.take() {
-                    if let Some(menu_builder) = self.menu_builder.clone() {
-                        *trigger_handle.0.borrow_mut() = Some(PopoverMenuHandleState {
-                            menu_builder,
-                            menu: element_state.menu.clone(),
-                            on_open: self.on_open.clone(),
-                        });
-                    }
+                if let Some(trigger_handle) = self.trigger_handle.take()
+                    && let Some(menu_builder) = self.menu_builder.clone()
+                {
+                    *trigger_handle.0.borrow_mut() = Some(PopoverMenuHandleState {
+                        menu_builder,
+                        menu: element_state.menu.clone(),
+                        on_open: self.on_open.clone(),
+                    });
                 }
 
                 let child_layout_id = child_element

crates/ui/src/components/right_click_menu.rs πŸ”—

@@ -250,12 +250,11 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
 
                         window
                             .subscribe(&new_menu, cx, move |modal, _: &DismissEvent, window, cx| {
-                                if modal.focus_handle(cx).contains_focused(window, cx) {
-                                    if let Some(previous_focus_handle) =
+                                if modal.focus_handle(cx).contains_focused(window, cx)
+                                    && let Some(previous_focus_handle) =
                                         previous_focus_handle.as_ref()
-                                    {
-                                        window.focus(previous_focus_handle);
-                                    }
+                                {
+                                    window.focus(previous_focus_handle);
                                 }
                                 *menu2.borrow_mut() = None;
                                 window.refresh();

crates/util/src/fs.rs πŸ”—

@@ -13,13 +13,13 @@ where
         while let Some(entry) = entries.next().await {
             if let Some(entry) = entry.log_err() {
                 let entry_path = entry.path();
-                if predicate(entry_path.as_path()) {
-                    if let Ok(metadata) = fs::metadata(&entry_path).await {
-                        if metadata.is_file() {
-                            fs::remove_file(&entry_path).await.log_err();
-                        } else {
-                            fs::remove_dir_all(&entry_path).await.log_err();
-                        }
+                if predicate(entry_path.as_path())
+                    && let Ok(metadata) = fs::metadata(&entry_path).await
+                {
+                    if metadata.is_file() {
+                        fs::remove_file(&entry_path).await.log_err();
+                    } else {
+                        fs::remove_dir_all(&entry_path).await.log_err();
                     }
                 }
             }
@@ -35,10 +35,10 @@ where
 
     if let Some(mut entries) = fs::read_dir(dir).await.log_err() {
         while let Some(entry) = entries.next().await {
-            if let Some(entry) = entry.log_err() {
-                if predicate(entry.path().as_path()) {
-                    matching.push(entry.path());
-                }
+            if let Some(entry) = entry.log_err()
+                && predicate(entry.path().as_path())
+            {
+                matching.push(entry.path());
             }
         }
     }
@@ -58,10 +58,9 @@ where
                 if let Some(file_name) = entry_path
                     .file_name()
                     .map(|file_name| file_name.to_string_lossy())
+                    && predicate(&file_name)
                 {
-                    if predicate(&file_name) {
-                        return Some(entry_path);
-                    }
+                    return Some(entry_path);
                 }
             }
         }

crates/util/src/schemars.rs πŸ”—

@@ -44,13 +44,12 @@ pub struct DefaultDenyUnknownFields;
 
 impl schemars::transform::Transform for DefaultDenyUnknownFields {
     fn transform(&mut self, schema: &mut schemars::Schema) {
-        if let Some(object) = schema.as_object_mut() {
-            if object.contains_key("properties")
-                && !object.contains_key("additionalProperties")
-                && !object.contains_key("unevaluatedProperties")
-            {
-                object.insert("additionalProperties".to_string(), false.into());
-            }
+        if let Some(object) = schema.as_object_mut()
+            && object.contains_key("properties")
+            && !object.contains_key("additionalProperties")
+            && !object.contains_key("unevaluatedProperties")
+        {
+            object.insert("additionalProperties".to_string(), false.into());
         }
         transform_subschemas(self, schema);
     }

crates/util/src/util.rs πŸ”—

@@ -128,11 +128,9 @@ pub fn truncate_lines_to_byte_limit(s: &str, max_bytes: usize) -> &str {
     }
 
     for i in (0..max_bytes).rev() {
-        if s.is_char_boundary(i) {
-            if s.as_bytes()[i] == b'\n' {
-                // Since the i-th character is \n, valid to slice at i + 1.
-                return &s[..i + 1];
-            }
+        if s.is_char_boundary(i) && s.as_bytes()[i] == b'\n' {
+            // Since the i-th character is \n, valid to slice at i + 1.
+            return &s[..i + 1];
         }
     }
 

crates/vim/src/command.rs πŸ”—

@@ -510,17 +510,16 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
                     vim.switch_mode(Mode::Normal, true, window, cx);
                 }
                 vim.update_editor(cx, |_, editor, cx| {
-                    if let Some(first_sel) = initial_selections {
-                        if let Some(tx_id) = editor
+                    if let Some(first_sel) = initial_selections
+                        && let Some(tx_id) = editor
                             .buffer()
                             .update(cx, |multi, cx| multi.last_transaction_id(cx))
-                        {
-                            let last_sel = editor.selections.disjoint_anchors();
-                            editor.modify_transaction_selection_history(tx_id, |old| {
-                                old.0 = first_sel;
-                                old.1 = Some(last_sel);
-                            });
-                        }
+                    {
+                        let last_sel = editor.selections.disjoint_anchors();
+                        editor.modify_transaction_selection_history(tx_id, |old| {
+                            old.0 = first_sel;
+                            old.1 = Some(last_sel);
+                        });
                     }
                 });
             })
@@ -1713,14 +1712,12 @@ impl Vim {
             match c {
                 '%' => {
                     self.update_editor(cx, |_, editor, cx| {
-                        if let Some((_, buffer, _)) = editor.active_excerpt(cx) {
-                            if let Some(file) = buffer.read(cx).file() {
-                                if let Some(local) = file.as_local() {
-                                    if let Some(str) = local.path().to_str() {
-                                        ret.push_str(str)
-                                    }
-                                }
-                            }
+                        if let Some((_, buffer, _)) = editor.active_excerpt(cx)
+                            && let Some(file) = buffer.read(cx).file()
+                            && let Some(local) = file.as_local()
+                            && let Some(str) = local.path().to_str()
+                        {
+                            ret.push_str(str)
                         }
                     });
                 }
@@ -1954,19 +1951,19 @@ impl ShellExec {
                 return;
             };
 
-            if let Some(mut stdin) = running.stdin.take() {
-                if let Some(snapshot) = input_snapshot {
-                    let range = range.clone();
-                    cx.background_spawn(async move {
-                        for chunk in snapshot.text_for_range(range) {
-                            if stdin.write_all(chunk.as_bytes()).log_err().is_none() {
-                                return;
-                            }
+            if let Some(mut stdin) = running.stdin.take()
+                && let Some(snapshot) = input_snapshot
+            {
+                let range = range.clone();
+                cx.background_spawn(async move {
+                    for chunk in snapshot.text_for_range(range) {
+                        if stdin.write_all(chunk.as_bytes()).log_err().is_none() {
+                            return;
                         }
-                        stdin.flush().log_err();
-                    })
-                    .detach();
-                }
+                    }
+                    stdin.flush().log_err();
+                })
+                .detach();
             };
 
             let output = cx

crates/vim/src/digraph.rs πŸ”—

@@ -63,15 +63,15 @@ impl Vim {
     }
 
     fn literal(&mut self, action: &Literal, window: &mut Window, cx: &mut Context<Self>) {
-        if let Some(Operator::Literal { prefix }) = self.active_operator() {
-            if let Some(prefix) = prefix {
-                if let Some(keystroke) = Keystroke::parse(&action.0).ok() {
-                    window.defer(cx, |window, cx| {
-                        window.dispatch_keystroke(keystroke, cx);
-                    });
-                }
-                return self.handle_literal_input(prefix, "", window, cx);
+        if let Some(Operator::Literal { prefix }) = self.active_operator()
+            && let Some(prefix) = prefix
+        {
+            if let Some(keystroke) = Keystroke::parse(&action.0).ok() {
+                window.defer(cx, |window, cx| {
+                    window.dispatch_keystroke(keystroke, cx);
+                });
             }
+            return self.handle_literal_input(prefix, "", window, cx);
         }
 
         self.insert_literal(Some(action.1), "", window, cx);

crates/vim/src/motion.rs πŸ”—

@@ -1811,10 +1811,10 @@ fn previous_word_end(
         .ignore_punctuation(ignore_punctuation);
     let mut point = point.to_point(map);
 
-    if point.column < map.buffer_snapshot.line_len(MultiBufferRow(point.row)) {
-        if let Some(ch) = map.buffer_snapshot.chars_at(point).next() {
-            point.column += ch.len_utf8() as u32;
-        }
+    if point.column < map.buffer_snapshot.line_len(MultiBufferRow(point.row))
+        && let Some(ch) = map.buffer_snapshot.chars_at(point).next()
+    {
+        point.column += ch.len_utf8() as u32;
     }
     for _ in 0..times {
         let new_point = movement::find_preceding_boundary_point(
@@ -1986,10 +1986,10 @@ fn previous_subword_end(
         .ignore_punctuation(ignore_punctuation);
     let mut point = point.to_point(map);
 
-    if point.column < map.buffer_snapshot.line_len(MultiBufferRow(point.row)) {
-        if let Some(ch) = map.buffer_snapshot.chars_at(point).next() {
-            point.column += ch.len_utf8() as u32;
-        }
+    if point.column < map.buffer_snapshot.line_len(MultiBufferRow(point.row))
+        && let Some(ch) = map.buffer_snapshot.chars_at(point).next()
+    {
+        point.column += ch.len_utf8() as u32;
     }
     for _ in 0..times {
         let new_point = movement::find_preceding_boundary_point(
@@ -2054,10 +2054,10 @@ pub(crate) fn last_non_whitespace(
     let classifier = map.buffer_snapshot.char_classifier_at(from.to_point(map));
 
     // NOTE: depending on clip_at_line_end we may already be one char back from the end.
-    if let Some((ch, _)) = map.buffer_chars_at(end_of_line).next() {
-        if classifier.kind(ch) != CharKind::Whitespace {
-            return end_of_line.to_display_point(map);
-        }
+    if let Some((ch, _)) = map.buffer_chars_at(end_of_line).next()
+        && classifier.kind(ch) != CharKind::Whitespace
+    {
+        return end_of_line.to_display_point(map);
     }
 
     for (ch, offset) in map.reverse_buffer_chars_at(end_of_line) {

crates/vim/src/normal/delete.rs πŸ”—

@@ -74,10 +74,10 @@ impl Vim {
                 editor.change_selections(Default::default(), window, cx, |s| {
                     s.move_with(|map, selection| {
                         let mut cursor = selection.head();
-                        if kind.linewise() {
-                            if let Some(column) = original_columns.get(&selection.id) {
-                                *cursor.column_mut() = *column
-                            }
+                        if kind.linewise()
+                            && let Some(column) = original_columns.get(&selection.id)
+                        {
+                            *cursor.column_mut() = *column
                         }
                         cursor = map.clip_point(cursor, Bias::Left);
                         selection.collapse_to(cursor, selection.goal)

crates/vim/src/normal/mark.rs πŸ”—

@@ -256,10 +256,8 @@ impl Vim {
                 }
             });
 
-            if should_jump {
-                if let Some(anchor) = anchor {
-                    self.motion(Motion::Jump { anchor, line }, window, cx)
-                }
+            if should_jump && let Some(anchor) = anchor {
+                self.motion(Motion::Jump { anchor, line }, window, cx)
             }
         }
     }

crates/vim/src/normal/repeat.rs πŸ”—

@@ -221,14 +221,14 @@ impl Vim {
             if actions.is_empty() {
                 return None;
             }
-            if globals.replayer.is_none() {
-                if let Some(recording_register) = globals.recording_register {
-                    globals
-                        .recordings
-                        .entry(recording_register)
-                        .or_default()
-                        .push(ReplayableAction::Action(Repeat.boxed_clone()));
-                }
+            if globals.replayer.is_none()
+                && let Some(recording_register) = globals.recording_register
+            {
+                globals
+                    .recordings
+                    .entry(recording_register)
+                    .or_default()
+                    .push(ReplayableAction::Action(Repeat.boxed_clone()));
             }
 
             let mut mode = None;
@@ -320,10 +320,10 @@ impl Vim {
         // vim doesn't treat 3a1 as though you literally repeated a1
         // 3 times, instead it inserts the content thrice at the insert position.
         if let Some(to_repeat) = repeatable_insert(&actions[0]) {
-            if let Some(ReplayableAction::Action(action)) = actions.last() {
-                if NormalBefore.partial_eq(&**action) {
-                    actions.pop();
-                }
+            if let Some(ReplayableAction::Action(action)) = actions.last()
+                && NormalBefore.partial_eq(&**action)
+            {
+                actions.pop();
             }
 
             let mut new_actions = actions.clone();

crates/vim/src/object.rs πŸ”—

@@ -100,10 +100,10 @@ fn cover_or_next<I: Iterator<Item = (Range<usize>, Range<usize>)>>(
         for (open_range, close_range) in ranges {
             let start_off = open_range.start;
             let end_off = close_range.end;
-            if let Some(range_filter) = range_filter {
-                if !range_filter(open_range.clone(), close_range.clone()) {
-                    continue;
-                }
+            if let Some(range_filter) = range_filter
+                && !range_filter(open_range.clone(), close_range.clone())
+            {
+                continue;
             }
             let candidate = CandidateWithRanges {
                 candidate: CandidateRange {
@@ -1060,11 +1060,11 @@ fn text_object(
         .filter_map(|(r, m)| if m == target { Some(r) } else { None })
         .collect();
     matches.sort_by_key(|r| r.start);
-    if let Some(buffer_range) = matches.first() {
-        if !buffer_range.is_empty() {
-            let range = excerpt.map_range_from_buffer(buffer_range.clone());
-            return Some(range.start.to_display_point(map)..range.end.to_display_point(map));
-        }
+    if let Some(buffer_range) = matches.first()
+        && !buffer_range.is_empty()
+    {
+        let range = excerpt.map_range_from_buffer(buffer_range.clone());
+        return Some(range.start.to_display_point(map)..range.end.to_display_point(map));
     }
     let buffer_range = excerpt.map_range_from_buffer(around_range.clone());
     return Some(buffer_range.start.to_display_point(map)..buffer_range.end.to_display_point(map));
@@ -1529,25 +1529,25 @@ fn surrounding_markers(
         Some((ch, _)) => ch,
         _ => '\0',
     };
-    if let Some((ch, range)) = movement::chars_after(map, point).next() {
-        if ch == open_marker && before_ch != '\\' {
-            if open_marker == close_marker {
-                let mut total = 0;
-                for ((ch, _), (before_ch, _)) in movement::chars_before(map, point).tuple_windows()
-                {
-                    if ch == '\n' {
-                        break;
-                    }
-                    if ch == open_marker && before_ch != '\\' {
-                        total += 1;
-                    }
+    if let Some((ch, range)) = movement::chars_after(map, point).next()
+        && ch == open_marker
+        && before_ch != '\\'
+    {
+        if open_marker == close_marker {
+            let mut total = 0;
+            for ((ch, _), (before_ch, _)) in movement::chars_before(map, point).tuple_windows() {
+                if ch == '\n' {
+                    break;
                 }
-                if total % 2 == 0 {
-                    opening = Some(range)
+                if ch == open_marker && before_ch != '\\' {
+                    total += 1;
                 }
-            } else {
+            }
+            if total % 2 == 0 {
                 opening = Some(range)
             }
+        } else {
+            opening = Some(range)
         }
     }
 
@@ -1558,10 +1558,10 @@ fn surrounding_markers(
                 break;
             }
 
-            if let Some((before_ch, _)) = chars_before.peek() {
-                if *before_ch == '\\' {
-                    continue;
-                }
+            if let Some((before_ch, _)) = chars_before.peek()
+                && *before_ch == '\\'
+            {
+                continue;
             }
 
             if ch == open_marker {

crates/vim/src/state.rs πŸ”—

@@ -412,20 +412,20 @@ impl MarksState {
         let mut to_write = HashMap::default();
 
         for (key, value) in &new_points {
-            if self.is_global_mark(key) {
-                if self.global_marks.get(key) != Some(&MarkLocation::Path(path.clone())) {
-                    if let Some(workspace_id) = self.workspace_id(cx) {
-                        let path = path.clone();
-                        let key = key.clone();
-                        cx.background_spawn(async move {
-                            DB.set_global_mark_path(workspace_id, key, path).await
-                        })
-                        .detach_and_log_err(cx);
-                    }
-
-                    self.global_marks
-                        .insert(key.clone(), MarkLocation::Path(path.clone()));
+            if self.is_global_mark(key)
+                && self.global_marks.get(key) != Some(&MarkLocation::Path(path.clone()))
+            {
+                if let Some(workspace_id) = self.workspace_id(cx) {
+                    let path = path.clone();
+                    let key = key.clone();
+                    cx.background_spawn(async move {
+                        DB.set_global_mark_path(workspace_id, key, path).await
+                    })
+                    .detach_and_log_err(cx);
                 }
+
+                self.global_marks
+                    .insert(key.clone(), MarkLocation::Path(path.clone()));
             }
             if old_points.and_then(|o| o.get(key)) != Some(value) {
                 to_write.insert(key.clone(), value.clone());
@@ -456,15 +456,15 @@ impl MarksState {
         buffer: &Entity<Buffer>,
         cx: &mut Context<Self>,
     ) {
-        if let MarkLocation::Buffer(entity_id) = old_path {
-            if let Some(old_marks) = self.multibuffer_marks.remove(&entity_id) {
-                let buffer_marks = old_marks
-                    .into_iter()
-                    .map(|(k, v)| (k, v.into_iter().map(|anchor| anchor.text_anchor).collect()))
-                    .collect();
-                self.buffer_marks
-                    .insert(buffer.read(cx).remote_id(), buffer_marks);
-            }
+        if let MarkLocation::Buffer(entity_id) = old_path
+            && let Some(old_marks) = self.multibuffer_marks.remove(&entity_id)
+        {
+            let buffer_marks = old_marks
+                .into_iter()
+                .map(|(k, v)| (k, v.into_iter().map(|anchor| anchor.text_anchor).collect()))
+                .collect();
+            self.buffer_marks
+                .insert(buffer.read(cx).remote_id(), buffer_marks);
         }
         self.watch_buffer(MarkLocation::Path(new_path.clone()), buffer, cx);
         self.serialize_buffer_marks(new_path, buffer, cx);
@@ -512,10 +512,9 @@ impl MarksState {
                     .watched_buffers
                     .get(&buffer_id.clone())
                     .map(|(path, _, _)| path.clone())
+                    && let Some(new_path) = this.path_for_buffer(&buffer, cx)
                 {
-                    if let Some(new_path) = this.path_for_buffer(&buffer, cx) {
-                        this.rename_buffer(old_path, new_path, &buffer, cx)
-                    }
+                    this.rename_buffer(old_path, new_path, &buffer, cx)
                 }
             }
             _ => {}
@@ -897,13 +896,13 @@ impl VimGlobals {
                 self.stop_recording_after_next_action = false;
             }
         }
-        if self.replayer.is_none() {
-            if let Some(recording_register) = self.recording_register {
-                self.recordings
-                    .entry(recording_register)
-                    .or_default()
-                    .push(ReplayableAction::Action(action));
-            }
+        if self.replayer.is_none()
+            && let Some(recording_register) = self.recording_register
+        {
+            self.recordings
+                .entry(recording_register)
+                .or_default()
+                .push(ReplayableAction::Action(action));
         }
     }
 
@@ -1330,10 +1329,10 @@ impl MarksMatchInfo {
         let mut offset = 0;
         for chunk in chunks {
             line.push_str(chunk.text);
-            if let Some(highlight_style) = chunk.syntax_highlight_id {
-                if let Some(highlight) = highlight_style.style(cx.theme().syntax()) {
-                    highlights.push((offset..offset + chunk.text.len(), highlight))
-                }
+            if let Some(highlight_style) = chunk.syntax_highlight_id
+                && let Some(highlight) = highlight_style.style(cx.theme().syntax())
+            {
+                highlights.push((offset..offset + chunk.text.len(), highlight))
             }
             offset += chunk.text.len();
         }

crates/vim/src/surrounds.rs πŸ”—

@@ -174,12 +174,11 @@ impl Vim {
                             if ch.to_string() == pair.start {
                                 let start = offset;
                                 let mut end = start + 1;
-                                if surround {
-                                    if let Some((next_ch, _)) = chars_and_offset.peek() {
-                                        if next_ch.eq(&' ') {
-                                            end += 1;
-                                        }
-                                    }
+                                if surround
+                                    && let Some((next_ch, _)) = chars_and_offset.peek()
+                                    && next_ch.eq(&' ')
+                                {
+                                    end += 1;
                                 }
                                 edits.push((start..end, ""));
                                 anchors.push(start..start);
@@ -193,12 +192,11 @@ impl Vim {
                             if ch.to_string() == pair.end {
                                 let mut start = offset;
                                 let end = start + 1;
-                                if surround {
-                                    if let Some((next_ch, _)) = reverse_chars_and_offsets.peek() {
-                                        if next_ch.eq(&' ') {
-                                            start -= 1;
-                                        }
-                                    }
+                                if surround
+                                    && let Some((next_ch, _)) = reverse_chars_and_offsets.peek()
+                                    && next_ch.eq(&' ')
+                                {
+                                    start -= 1;
                                 }
                                 edits.push((start..end, ""));
                                 break;

crates/vim/src/test/neovim_connection.rs πŸ”—

@@ -217,10 +217,11 @@ impl NeovimConnection {
                 .expect("Could not set nvim cursor position");
         }
 
-        if let Some(NeovimData::Get { mode, state }) = self.data.back() {
-            if *mode == Mode::Normal && *state == marked_text {
-                return;
-            }
+        if let Some(NeovimData::Get { mode, state }) = self.data.back()
+            && *mode == Mode::Normal
+            && *state == marked_text
+        {
+            return;
         }
         self.data.push_back(NeovimData::Put {
             state: marked_text.to_string(),

crates/vim/src/vim.rs πŸ”—

@@ -788,10 +788,10 @@ impl Vim {
         editor.selections.line_mode = false;
         editor.unregister_addon::<VimAddon>();
         editor.set_relative_line_number(None, cx);
-        if let Some(vim) = Vim::globals(cx).focused_vim() {
-            if vim.entity_id() == cx.entity().entity_id() {
-                Vim::globals(cx).focused_vim = None;
-            }
+        if let Some(vim) = Vim::globals(cx).focused_vim()
+            && vim.entity_id() == cx.entity().entity_id()
+        {
+            Vim::globals(cx).focused_vim = None;
         }
     }
 
@@ -833,10 +833,10 @@ impl Vim {
         if self.exit_temporary_mode {
             self.exit_temporary_mode = false;
             // Don't switch to insert mode if the action is temporary_normal.
-            if let Some(action) = keystroke_event.action.as_ref() {
-                if action.as_any().downcast_ref::<TemporaryNormal>().is_some() {
-                    return;
-                }
+            if let Some(action) = keystroke_event.action.as_ref()
+                && action.as_any().downcast_ref::<TemporaryNormal>().is_some()
+            {
+                return;
             }
             self.switch_mode(Mode::Insert, false, window, cx)
         }
@@ -1006,10 +1006,10 @@ impl Vim {
                     Some((point, goal))
                 })
             }
-            if last_mode == Mode::Insert || last_mode == Mode::Replace {
-                if let Some(prior_tx) = prior_tx {
-                    editor.group_until_transaction(prior_tx, cx)
-                }
+            if (last_mode == Mode::Insert || last_mode == Mode::Replace)
+                && let Some(prior_tx) = prior_tx
+            {
+                editor.group_until_transaction(prior_tx, cx)
             }
 
             editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
@@ -1031,14 +1031,16 @@ impl Vim {
                 }
 
                 let snapshot = s.display_map();
-                if let Some(pending) = s.pending.as_mut() {
-                    if pending.selection.reversed && mode.is_visual() && !last_mode.is_visual() {
-                        let mut end = pending.selection.end.to_point(&snapshot.buffer_snapshot);
-                        end = snapshot
-                            .buffer_snapshot
-                            .clip_point(end + Point::new(0, 1), Bias::Right);
-                        pending.selection.end = snapshot.buffer_snapshot.anchor_before(end);
-                    }
+                if let Some(pending) = s.pending.as_mut()
+                    && pending.selection.reversed
+                    && mode.is_visual()
+                    && !last_mode.is_visual()
+                {
+                    let mut end = pending.selection.end.to_point(&snapshot.buffer_snapshot);
+                    end = snapshot
+                        .buffer_snapshot
+                        .clip_point(end + Point::new(0, 1), Bias::Right);
+                    pending.selection.end = snapshot.buffer_snapshot.anchor_before(end);
                 }
 
                 s.move_with(|map, selection| {
@@ -1536,12 +1538,12 @@ impl Vim {
         if self.mode == Mode::Insert && self.current_tx.is_some() {
             if self.current_anchor.is_none() {
                 self.current_anchor = Some(newest);
-            } else if self.current_anchor.as_ref().unwrap() != &newest {
-                if let Some(tx_id) = self.current_tx.take() {
-                    self.update_editor(cx, |_, editor, cx| {
-                        editor.group_until_transaction(tx_id, cx)
-                    });
-                }
+            } else if self.current_anchor.as_ref().unwrap() != &newest
+                && let Some(tx_id) = self.current_tx.take()
+            {
+                self.update_editor(cx, |_, editor, cx| {
+                    editor.group_until_transaction(tx_id, cx)
+                });
             }
         } else if self.mode == Mode::Normal && newest.start != newest.end {
             if matches!(newest.goal, SelectionGoal::HorizontalRange { .. }) {

crates/workspace/src/dock.rs πŸ”—

@@ -305,15 +305,14 @@ impl Dock {
         .detach();
 
         cx.observe_in(&dock, window, move |workspace, dock, window, cx| {
-            if dock.read(cx).is_open() {
-                if let Some(panel) = dock.read(cx).active_panel() {
-                    if panel.is_zoomed(window, cx) {
-                        workspace.zoomed = Some(panel.to_any().downgrade());
-                        workspace.zoomed_position = Some(position);
-                        cx.emit(Event::ZoomChanged);
-                        return;
-                    }
-                }
+            if dock.read(cx).is_open()
+                && let Some(panel) = dock.read(cx).active_panel()
+                && panel.is_zoomed(window, cx)
+            {
+                workspace.zoomed = Some(panel.to_any().downgrade());
+                workspace.zoomed_position = Some(position);
+                cx.emit(Event::ZoomChanged);
+                return;
             }
             if workspace.zoomed_position == Some(position) {
                 workspace.zoomed = None;
@@ -541,10 +540,10 @@ impl Dock {
             Ok(ix) => ix,
             Err(ix) => ix,
         };
-        if let Some(active_index) = self.active_panel_index.as_mut() {
-            if *active_index >= index {
-                *active_index += 1;
-            }
+        if let Some(active_index) = self.active_panel_index.as_mut()
+            && *active_index >= index
+        {
+            *active_index += 1;
         }
         self.panel_entries.insert(
             index,
@@ -566,16 +565,16 @@ impl Dock {
 
     pub fn restore_state(&mut self, window: &mut Window, cx: &mut Context<Self>) -> bool {
         if let Some(serialized) = self.serialized_dock.clone() {
-            if let Some(active_panel) = serialized.active_panel.filter(|_| serialized.visible) {
-                if let Some(idx) = self.panel_index_for_persistent_name(active_panel.as_str(), cx) {
-                    self.activate_panel(idx, window, cx);
-                }
+            if let Some(active_panel) = serialized.active_panel.filter(|_| serialized.visible)
+                && let Some(idx) = self.panel_index_for_persistent_name(active_panel.as_str(), cx)
+            {
+                self.activate_panel(idx, window, cx);
             }
 
-            if serialized.zoom {
-                if let Some(panel) = self.active_panel() {
-                    panel.set_zoomed(true, window, cx)
-                }
+            if serialized.zoom
+                && let Some(panel) = self.active_panel()
+            {
+                panel.set_zoomed(true, window, cx)
             }
             self.set_open(serialized.visible, window, cx);
             return true;

crates/workspace/src/history_manager.rs πŸ”—

@@ -101,11 +101,11 @@ impl HistoryManager {
         }
         let mut deleted_ids = Vec::new();
         for idx in (0..self.history.len()).rev() {
-            if let Some(entry) = self.history.get(idx) {
-                if user_removed.contains(&entry.path) {
-                    deleted_ids.push(entry.id);
-                    self.history.remove(idx);
-                }
+            if let Some(entry) = self.history.get(idx)
+                && user_removed.contains(&entry.path)
+            {
+                deleted_ids.push(entry.id);
+                self.history.remove(idx);
             }
         }
         cx.spawn(async move |_| {

crates/workspace/src/item.rs πŸ”—

@@ -832,10 +832,10 @@ impl<T: Item> ItemHandle for Entity<T> {
                     if let Some(item) = item.to_followable_item_handle(cx) {
                         let leader_id = workspace.leader_for_pane(&pane);
 
-                        if let Some(leader_id) = leader_id {
-                            if let Some(FollowEvent::Unfollow) = item.to_follow_event(event) {
-                                workspace.unfollow(leader_id, window, cx);
-                            }
+                        if let Some(leader_id) = leader_id
+                            && let Some(FollowEvent::Unfollow) = item.to_follow_event(event)
+                        {
+                            workspace.unfollow(leader_id, window, cx);
                         }
 
                         if item.item_focus_handle(cx).contains_focused(window, cx) {
@@ -863,10 +863,10 @@ impl<T: Item> ItemHandle for Entity<T> {
                         }
                     }
 
-                    if let Some(item) = item.to_serializable_item_handle(cx) {
-                        if item.should_serialize(event, cx) {
-                            workspace.enqueue_item_serialization(item).ok();
-                        }
+                    if let Some(item) = item.to_serializable_item_handle(cx)
+                        && item.should_serialize(event, cx)
+                    {
+                        workspace.enqueue_item_serialization(item).ok();
                     }
 
                     T::to_item_events(event, |event| match event {
@@ -948,11 +948,11 @@ impl<T: Item> ItemHandle for Entity<T> {
                 &self.read(cx).focus_handle(cx),
                 window,
                 move |workspace, window, cx| {
-                    if let Some(item) = weak_item.upgrade() {
-                        if item.workspace_settings(cx).autosave == AutosaveSetting::OnFocusChange {
-                            Pane::autosave_item(&item, workspace.project.clone(), window, cx)
-                                .detach_and_log_err(cx);
-                        }
+                    if let Some(item) = weak_item.upgrade()
+                        && item.workspace_settings(cx).autosave == AutosaveSetting::OnFocusChange
+                    {
+                        Pane::autosave_item(&item, workspace.project.clone(), window, cx)
+                            .detach_and_log_err(cx);
                     }
                 },
             )

crates/workspace/src/modal_layer.rs πŸ”—

@@ -141,10 +141,10 @@ impl ModalLayer {
         }
 
         if let Some(active_modal) = self.active_modal.take() {
-            if let Some(previous_focus) = active_modal.previous_focus_handle {
-                if active_modal.focus_handle.contains_focused(window, cx) {
-                    previous_focus.focus(window);
-                }
+            if let Some(previous_focus) = active_modal.previous_focus_handle
+                && active_modal.focus_handle.contains_focused(window, cx)
+            {
+                previous_focus.focus(window);
             }
             cx.notify();
         }

crates/workspace/src/pane.rs πŸ”—

@@ -580,19 +580,18 @@ impl Pane {
                 // or focus the active item itself
                 if let Some(weak_last_focus_handle) =
                     self.last_focus_handle_by_item.get(&active_item.item_id())
+                    && let Some(focus_handle) = weak_last_focus_handle.upgrade()
                 {
-                    if let Some(focus_handle) = weak_last_focus_handle.upgrade() {
-                        focus_handle.focus(window);
-                        return;
-                    }
+                    focus_handle.focus(window);
+                    return;
                 }
 
                 active_item.item_focus_handle(cx).focus(window);
-            } else if let Some(focused) = window.focused(cx) {
-                if !self.context_menu_focused(window, cx) {
-                    self.last_focus_handle_by_item
-                        .insert(active_item.item_id(), focused.downgrade());
-                }
+            } else if let Some(focused) = window.focused(cx)
+                && !self.context_menu_focused(window, cx)
+            {
+                self.last_focus_handle_by_item
+                    .insert(active_item.item_id(), focused.downgrade());
             }
         }
     }
@@ -858,10 +857,11 @@ impl Pane {
     }
 
     pub fn handle_item_edit(&mut self, item_id: EntityId, cx: &App) {
-        if let Some(preview_item) = self.preview_item() {
-            if preview_item.item_id() == item_id && !preview_item.preserve_preview(cx) {
-                self.set_preview_item_id(None, cx);
-            }
+        if let Some(preview_item) = self.preview_item()
+            && preview_item.item_id() == item_id
+            && !preview_item.preserve_preview(cx)
+        {
+            self.set_preview_item_id(None, cx);
         }
     }
 
@@ -900,12 +900,12 @@ impl Pane {
         if let Some((index, existing_item)) = existing_item {
             // If the item is already open, and the item is a preview item
             // and we are not allowing items to open as preview, mark the item as persistent.
-            if let Some(preview_item_id) = self.preview_item_id {
-                if let Some(tab) = self.items.get(index) {
-                    if tab.item_id() == preview_item_id && !allow_preview {
-                        self.set_preview_item_id(None, cx);
-                    }
-                }
+            if let Some(preview_item_id) = self.preview_item_id
+                && let Some(tab) = self.items.get(index)
+                && tab.item_id() == preview_item_id
+                && !allow_preview
+            {
+                self.set_preview_item_id(None, cx);
             }
             if activate {
                 self.activate_item(index, focus_item, focus_item, window, cx);
@@ -977,21 +977,21 @@ impl Pane {
             self.close_items_on_item_open(window, cx);
         }
 
-        if item.is_singleton(cx) {
-            if let Some(&entry_id) = item.project_entry_ids(cx).first() {
-                let Some(project) = self.project.upgrade() else {
-                    return;
-                };
+        if item.is_singleton(cx)
+            && let Some(&entry_id) = item.project_entry_ids(cx).first()
+        {
+            let Some(project) = self.project.upgrade() else {
+                return;
+            };
 
-                let project = project.read(cx);
-                if let Some(project_path) = project.path_for_entry(entry_id, cx) {
-                    let abs_path = project.absolute_path(&project_path, cx);
-                    self.nav_history
-                        .0
-                        .lock()
-                        .paths_by_item
-                        .insert(item.item_id(), (project_path, abs_path));
-                }
+            let project = project.read(cx);
+            if let Some(project_path) = project.path_for_entry(entry_id, cx) {
+                let abs_path = project.absolute_path(&project_path, cx);
+                self.nav_history
+                    .0
+                    .lock()
+                    .paths_by_item
+                    .insert(item.item_id(), (project_path, abs_path));
             }
         }
         // If no destination index is specified, add or move the item after the
@@ -1192,12 +1192,11 @@ impl Pane {
         use NavigationMode::{GoingBack, GoingForward};
         if index < self.items.len() {
             let prev_active_item_ix = mem::replace(&mut self.active_item_index, index);
-            if prev_active_item_ix != self.active_item_index
-                || matches!(self.nav_history.mode(), GoingBack | GoingForward)
+            if (prev_active_item_ix != self.active_item_index
+                || matches!(self.nav_history.mode(), GoingBack | GoingForward))
+                && let Some(prev_item) = self.items.get(prev_active_item_ix)
             {
-                if let Some(prev_item) = self.items.get(prev_active_item_ix) {
-                    prev_item.deactivated(window, cx);
-                }
+                prev_item.deactivated(window, cx);
             }
             self.update_history(index);
             self.update_toolbar(window, cx);
@@ -2462,10 +2461,11 @@ impl Pane {
             .on_mouse_down(
                 MouseButton::Left,
                 cx.listener(move |pane, event: &MouseDownEvent, _, cx| {
-                    if let Some(id) = pane.preview_item_id {
-                        if id == item_id && event.click_count > 1 {
-                            pane.set_preview_item_id(None, cx);
-                        }
+                    if let Some(id) = pane.preview_item_id
+                        && id == item_id
+                        && event.click_count > 1
+                    {
+                        pane.set_preview_item_id(None, cx);
                     }
                 }),
             )
@@ -3048,18 +3048,18 @@ impl Pane {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
-            if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_tab, window, cx) {
-                return;
-            }
+        if let Some(custom_drop_handle) = self.custom_drop_handle.clone()
+            && let ControlFlow::Break(()) = custom_drop_handle(self, dragged_tab, window, cx)
+        {
+            return;
         }
         let mut to_pane = cx.entity();
         let split_direction = self.drag_split_direction;
         let item_id = dragged_tab.item.item_id();
-        if let Some(preview_item_id) = self.preview_item_id {
-            if item_id == preview_item_id {
-                self.set_preview_item_id(None, cx);
-            }
+        if let Some(preview_item_id) = self.preview_item_id
+            && item_id == preview_item_id
+        {
+            self.set_preview_item_id(None, cx);
         }
 
         let is_clone = cfg!(target_os = "macos") && window.modifiers().alt
@@ -3136,11 +3136,10 @@ impl Pane {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
-            if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_selection, window, cx)
-            {
-                return;
-            }
+        if let Some(custom_drop_handle) = self.custom_drop_handle.clone()
+            && let ControlFlow::Break(()) = custom_drop_handle(self, dragged_selection, window, cx)
+        {
+            return;
         }
         self.handle_project_entry_drop(
             &dragged_selection.active_selection.entry_id,
@@ -3157,10 +3156,10 @@ impl Pane {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
-            if let ControlFlow::Break(()) = custom_drop_handle(self, project_entry_id, window, cx) {
-                return;
-            }
+        if let Some(custom_drop_handle) = self.custom_drop_handle.clone()
+            && let ControlFlow::Break(()) = custom_drop_handle(self, project_entry_id, window, cx)
+        {
+            return;
         }
         let mut to_pane = cx.entity();
         let split_direction = self.drag_split_direction;
@@ -3233,10 +3232,10 @@ impl Pane {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) {
-        if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
-            if let ControlFlow::Break(()) = custom_drop_handle(self, paths, window, cx) {
-                return;
-            }
+        if let Some(custom_drop_handle) = self.custom_drop_handle.clone()
+            && let ControlFlow::Break(()) = custom_drop_handle(self, paths, window, cx)
+        {
+            return;
         }
         let mut to_pane = cx.entity();
         let mut split_direction = self.drag_split_direction;
@@ -3790,10 +3789,10 @@ impl NavHistory {
                     borrowed_history.paths_by_item.get(&entry.item.id())
                 {
                     f(entry, project_and_abs_path.clone());
-                } else if let Some(item) = entry.item.upgrade() {
-                    if let Some(path) = item.project_path(cx) {
-                        f(entry, (path, None));
-                    }
+                } else if let Some(item) = entry.item.upgrade()
+                    && let Some(path) = item.project_path(cx)
+                {
+                    f(entry, (path, None));
                 }
             })
     }

crates/workspace/src/pane_group.rs πŸ”—

@@ -619,15 +619,15 @@ impl PaneAxis {
         let mut found_axis_index: Option<usize> = None;
         if !found_pane {
             for (i, pa) in self.members.iter_mut().enumerate() {
-                if let Member::Axis(pa) = pa {
-                    if let Some(done) = pa.resize(pane, axis, amount, bounds) {
-                        if done {
-                            return Some(true); // pane found and operations already done
-                        } else if self.axis != axis {
-                            return Some(false); // pane found but this is not the correct axis direction
-                        } else {
-                            found_axis_index = Some(i); // pane found and this is correct direction
-                        }
+                if let Member::Axis(pa) = pa
+                    && let Some(done) = pa.resize(pane, axis, amount, bounds)
+                {
+                    if done {
+                        return Some(true); // pane found and operations already done
+                    } else if self.axis != axis {
+                        return Some(false); // pane found but this is not the correct axis direction
+                    } else {
+                        found_axis_index = Some(i); // pane found and this is correct direction
                     }
                 }
             }
@@ -743,13 +743,13 @@ impl PaneAxis {
         let bounding_boxes = self.bounding_boxes.lock();
 
         for (idx, member) in self.members.iter().enumerate() {
-            if let Some(coordinates) = bounding_boxes[idx] {
-                if coordinates.contains(&coordinate) {
-                    return match member {
-                        Member::Pane(found) => Some(found),
-                        Member::Axis(axis) => axis.pane_at_pixel_position(coordinate),
-                    };
-                }
+            if let Some(coordinates) = bounding_boxes[idx]
+                && coordinates.contains(&coordinate)
+            {
+                return match member {
+                    Member::Pane(found) => Some(found),
+                    Member::Axis(axis) => axis.pane_at_pixel_position(coordinate),
+                };
             }
         }
         None
@@ -1273,17 +1273,18 @@ mod element {
                         window.paint_quad(gpui::fill(overlay_bounds, overlay_background));
                     }
 
-                    if let Some(border) = overlay_border {
-                        if self.active_pane_ix == Some(ix) && child.is_leaf_pane {
-                            window.paint_quad(gpui::quad(
-                                overlay_bounds,
-                                0.,
-                                gpui::transparent_black(),
-                                border,
-                                cx.theme().colors().border_selected,
-                                BorderStyle::Solid,
-                            ));
-                        }
+                    if let Some(border) = overlay_border
+                        && self.active_pane_ix == Some(ix)
+                        && child.is_leaf_pane
+                    {
+                        window.paint_quad(gpui::quad(
+                            overlay_bounds,
+                            0.,
+                            gpui::transparent_black(),
+                            border,
+                            cx.theme().colors().border_selected,
+                            BorderStyle::Solid,
+                        ));
                     }
                 }
 

crates/workspace/src/workspace.rs πŸ”—

@@ -1345,18 +1345,18 @@ impl Workspace {
                         .timer(Duration::from_millis(100))
                         .await;
                     this.update_in(cx, |this, window, cx| {
-                        if let Some(display) = window.display(cx) {
-                            if let Ok(display_uuid) = display.uuid() {
-                                let window_bounds = window.inner_window_bounds();
-                                if let Some(database_id) = workspace_id {
-                                    cx.background_executor()
-                                        .spawn(DB.set_window_open_status(
-                                            database_id,
-                                            SerializedWindowBounds(window_bounds),
-                                            display_uuid,
-                                        ))
-                                        .detach_and_log_err(cx);
-                                }
+                        if let Some(display) = window.display(cx)
+                            && let Ok(display_uuid) = display.uuid()
+                        {
+                            let window_bounds = window.inner_window_bounds();
+                            if let Some(database_id) = workspace_id {
+                                cx.background_executor()
+                                    .spawn(DB.set_window_open_status(
+                                        database_id,
+                                        SerializedWindowBounds(window_bounds),
+                                        display_uuid,
+                                    ))
+                                    .detach_and_log_err(cx);
                             }
                         }
                         this.bounds_save_task_queued.take();
@@ -1729,13 +1729,12 @@ impl Workspace {
             let item_map: HashMap<EntityId, &Box<dyn ItemHandle>> =
                 pane.items().map(|item| (item.item_id(), item)).collect();
             for entry in pane.activation_history() {
-                if entry.timestamp > recent_timestamp {
-                    if let Some(&item) = item_map.get(&entry.entity_id) {
-                        if let Some(typed_item) = item.act_as::<T>(cx) {
-                            recent_timestamp = entry.timestamp;
-                            recent_item = Some(typed_item);
-                        }
-                    }
+                if entry.timestamp > recent_timestamp
+                    && let Some(&item) = item_map.get(&entry.entity_id)
+                    && let Some(typed_item) = item.act_as::<T>(cx)
+                {
+                    recent_timestamp = entry.timestamp;
+                    recent_item = Some(typed_item);
                 }
             }
         }
@@ -1774,19 +1773,19 @@ impl Workspace {
                     }
                 });
 
-            if let Some(item) = pane.active_item() {
-                if let Some(project_path) = item.project_path(cx) {
-                    let fs_path = self.project.read(cx).absolute_path(&project_path, cx);
-
-                    if let Some(fs_path) = &fs_path {
-                        abs_paths_opened
-                            .entry(fs_path.clone())
-                            .or_default()
-                            .insert(project_path.clone());
-                    }
+            if let Some(item) = pane.active_item()
+                && let Some(project_path) = item.project_path(cx)
+            {
+                let fs_path = self.project.read(cx).absolute_path(&project_path, cx);
 
-                    history.insert(project_path, (fs_path, std::usize::MAX));
+                if let Some(fs_path) = &fs_path {
+                    abs_paths_opened
+                        .entry(fs_path.clone())
+                        .or_default()
+                        .insert(project_path.clone());
                 }
+
+                history.insert(project_path, (fs_path, std::usize::MAX));
             }
         }
 
@@ -2250,29 +2249,28 @@ impl Workspace {
                     .count()
             })?;
 
-            if let Some(active_call) = active_call {
-                if close_intent != CloseIntent::Quit
-                    && workspace_count == 1
-                    && active_call.read_with(cx, |call, _| call.room().is_some())?
-                {
-                    let answer = cx.update(|window, cx| {
-                        window.prompt(
-                            PromptLevel::Warning,
-                            "Do you want to leave the current call?",
-                            None,
-                            &["Close window and hang up", "Cancel"],
-                            cx,
-                        )
-                    })?;
+            if let Some(active_call) = active_call
+                && close_intent != CloseIntent::Quit
+                && workspace_count == 1
+                && active_call.read_with(cx, |call, _| call.room().is_some())?
+            {
+                let answer = cx.update(|window, cx| {
+                    window.prompt(
+                        PromptLevel::Warning,
+                        "Do you want to leave the current call?",
+                        None,
+                        &["Close window and hang up", "Cancel"],
+                        cx,
+                    )
+                })?;
 
-                    if answer.await.log_err() == Some(1) {
-                        return anyhow::Ok(false);
-                    } else {
-                        active_call
-                            .update(cx, |call, cx| call.hang_up(cx))?
-                            .await
-                            .log_err();
-                    }
+                if answer.await.log_err() == Some(1) {
+                    return anyhow::Ok(false);
+                } else {
+                    active_call
+                        .update(cx, |call, cx| call.hang_up(cx))?
+                        .await
+                        .log_err();
                 }
             }
 
@@ -2448,10 +2446,10 @@ impl Workspace {
             for (pane, item) in dirty_items {
                 let (singleton, project_entry_ids) =
                     cx.update(|_, cx| (item.is_singleton(cx), item.project_entry_ids(cx)))?;
-                if singleton || !project_entry_ids.is_empty() {
-                    if !Pane::save_item(project.clone(), &pane, &*item, save_intent, cx).await? {
-                        return Ok(false);
-                    }
+                if (singleton || !project_entry_ids.is_empty())
+                    && !Pane::save_item(project.clone(), &pane, &*item, save_intent, cx).await?
+                {
+                    return Ok(false);
                 }
             }
             Ok(true)
@@ -3080,14 +3078,12 @@ impl Workspace {
         let mut focus_center = false;
         for dock in self.all_docks() {
             dock.update(cx, |dock, cx| {
-                if Some(dock.position()) != dock_to_reveal {
-                    if let Some(panel) = dock.active_panel() {
-                        if panel.is_zoomed(window, cx) {
-                            focus_center |=
-                                panel.panel_focus_handle(cx).contains_focused(window, cx);
-                            dock.set_open(false, window, cx);
-                        }
-                    }
+                if Some(dock.position()) != dock_to_reveal
+                    && let Some(panel) = dock.active_panel()
+                    && panel.is_zoomed(window, cx)
+                {
+                    focus_center |= panel.panel_focus_handle(cx).contains_focused(window, cx);
+                    dock.set_open(false, window, cx);
                 }
             });
         }
@@ -3328,10 +3324,10 @@ impl Workspace {
                 .downgrade()
         });
 
-        if let Member::Pane(center_pane) = &self.center.root {
-            if center_pane.read(cx).items_len() == 0 {
-                return self.open_path(path, Some(pane), true, window, cx);
-            }
+        if let Member::Pane(center_pane) = &self.center.root
+            && center_pane.read(cx).items_len() == 0
+        {
+            return self.open_path(path, Some(pane), true, window, cx);
         }
 
         let project_path = path.into();
@@ -3393,10 +3389,10 @@ impl Workspace {
         if let Some(entry_id) = entry_id {
             item = pane.read(cx).item_for_entry(entry_id, cx);
         }
-        if item.is_none() {
-            if let Some(project_path) = project_path {
-                item = pane.read(cx).item_for_path(project_path, cx);
-            }
+        if item.is_none()
+            && let Some(project_path) = project_path
+        {
+            item = pane.read(cx).item_for_path(project_path, cx);
         }
 
         item.and_then(|item| item.downcast::<T>())
@@ -3440,12 +3436,11 @@ impl Workspace {
         let item_id = item.item_id();
         let mut destination_index = None;
         pane.update(cx, |pane, cx| {
-            if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
-                if let Some(preview_item_id) = pane.preview_item_id() {
-                    if preview_item_id != item_id {
-                        destination_index = pane.close_current_preview_item(window, cx);
-                    }
-                }
+            if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation
+                && let Some(preview_item_id) = pane.preview_item_id()
+                && preview_item_id != item_id
+            {
+                destination_index = pane.close_current_preview_item(window, cx);
             }
             pane.set_preview_item_id(Some(item.item_id()), cx)
         });
@@ -3912,10 +3907,10 @@ impl Workspace {
             pane::Event::RemovedItem { item } => {
                 cx.emit(Event::ActiveItemChanged);
                 self.update_window_edited(window, cx);
-                if let hash_map::Entry::Occupied(entry) = self.panes_by_item.entry(item.item_id()) {
-                    if entry.get().entity_id() == pane.entity_id() {
-                        entry.remove();
-                    }
+                if let hash_map::Entry::Occupied(entry) = self.panes_by_item.entry(item.item_id())
+                    && entry.get().entity_id() == pane.entity_id()
+                {
+                    entry.remove();
                 }
             }
             pane::Event::Focus => {
@@ -4105,14 +4100,13 @@ impl Workspace {
 
     pub fn focused_pane(&self, window: &Window, cx: &App) -> Entity<Pane> {
         for dock in self.all_docks() {
-            if dock.focus_handle(cx).contains_focused(window, cx) {
-                if let Some(pane) = dock
+            if dock.focus_handle(cx).contains_focused(window, cx)
+                && let Some(pane) = dock
                     .read(cx)
                     .active_panel()
                     .and_then(|panel| panel.pane(cx))
-                {
-                    return pane;
-                }
+            {
+                return pane;
             }
         }
         self.active_pane().clone()
@@ -4393,10 +4387,10 @@ impl Workspace {
             title.push_str(" β†—");
         }
 
-        if let Some(last_title) = self.last_window_title.as_ref() {
-            if &title == last_title {
-                return;
-            }
+        if let Some(last_title) = self.last_window_title.as_ref()
+            && &title == last_title
+        {
+            return;
         }
         window.set_window_title(&title);
         self.last_window_title = Some(title);
@@ -4575,10 +4569,8 @@ impl Workspace {
                     }
                 })??;
 
-                if should_add_view {
-                    if let Some(view) = update_active_view.view {
-                        Self::add_view_from_leader(this.clone(), leader_id, &view, cx).await?
-                    }
+                if should_add_view && let Some(view) = update_active_view.view {
+                    Self::add_view_from_leader(this.clone(), leader_id, &view, cx).await?
                 }
             }
             proto::update_followers::Variant::UpdateView(update_view) => {
@@ -4774,40 +4766,40 @@ impl Workspace {
         if window.is_window_active() {
             let (active_item, panel_id) = self.active_item_for_followers(window, cx);
 
-            if let Some(item) = active_item {
-                if item.item_focus_handle(cx).contains_focused(window, cx) {
-                    let leader_id = self
-                        .pane_for(&*item)
-                        .and_then(|pane| self.leader_for_pane(&pane));
-                    let leader_peer_id = match leader_id {
-                        Some(CollaboratorId::PeerId(peer_id)) => Some(peer_id),
-                        Some(CollaboratorId::Agent) | None => None,
-                    };
+            if let Some(item) = active_item
+                && item.item_focus_handle(cx).contains_focused(window, cx)
+            {
+                let leader_id = self
+                    .pane_for(&*item)
+                    .and_then(|pane| self.leader_for_pane(&pane));
+                let leader_peer_id = match leader_id {
+                    Some(CollaboratorId::PeerId(peer_id)) => Some(peer_id),
+                    Some(CollaboratorId::Agent) | None => None,
+                };
 
-                    if let Some(item) = item.to_followable_item_handle(cx) {
-                        let id = item
-                            .remote_id(&self.app_state.client, window, cx)
-                            .map(|id| id.to_proto());
-
-                        if let Some(id) = id {
-                            if let Some(variant) = item.to_state_proto(window, cx) {
-                                let view = Some(proto::View {
-                                    id: id.clone(),
-                                    leader_id: leader_peer_id,
-                                    variant: Some(variant),
-                                    panel_id: panel_id.map(|id| id as i32),
-                                });
-
-                                is_project_item = item.is_project_item(window, cx);
-                                update = proto::UpdateActiveView {
-                                    view,
-                                    // TODO: Remove after version 0.145.x stabilizes.
-                                    id,
-                                    leader_id: leader_peer_id,
-                                };
-                            }
+                if let Some(item) = item.to_followable_item_handle(cx) {
+                    let id = item
+                        .remote_id(&self.app_state.client, window, cx)
+                        .map(|id| id.to_proto());
+
+                    if let Some(id) = id
+                        && let Some(variant) = item.to_state_proto(window, cx)
+                    {
+                        let view = Some(proto::View {
+                            id: id.clone(),
+                            leader_id: leader_peer_id,
+                            variant: Some(variant),
+                            panel_id: panel_id.map(|id| id as i32),
+                        });
+
+                        is_project_item = item.is_project_item(window, cx);
+                        update = proto::UpdateActiveView {
+                            view,
+                            // TODO: Remove after version 0.145.x stabilizes.
+                            id,
+                            leader_id: leader_peer_id,
                         };
-                    }
+                    };
                 }
             }
         }
@@ -4832,16 +4824,14 @@ impl Workspace {
         let mut active_item = None;
         let mut panel_id = None;
         for dock in self.all_docks() {
-            if dock.focus_handle(cx).contains_focused(window, cx) {
-                if let Some(panel) = dock.read(cx).active_panel() {
-                    if let Some(pane) = panel.pane(cx) {
-                        if let Some(item) = pane.read(cx).active_item() {
-                            active_item = Some(item);
-                            panel_id = panel.remote_id();
-                            break;
-                        }
-                    }
-                }
+            if dock.focus_handle(cx).contains_focused(window, cx)
+                && let Some(panel) = dock.read(cx).active_panel()
+                && let Some(pane) = panel.pane(cx)
+                && let Some(item) = pane.read(cx).active_item()
+            {
+                active_item = Some(item);
+                panel_id = panel.remote_id();
+                break;
             }
         }
 
@@ -4969,10 +4959,10 @@ impl Workspace {
         let state = self.follower_states.get(&peer_id.into())?;
         let mut item_to_activate = None;
         if let (Some(active_view_id), true) = (state.active_view_id, leader_in_this_app) {
-            if let Some(item) = state.items_by_leader_view_id.get(&active_view_id) {
-                if leader_in_this_project || !item.view.is_project_item(window, cx) {
-                    item_to_activate = Some((item.location, item.view.boxed_clone()));
-                }
+            if let Some(item) = state.items_by_leader_view_id.get(&active_view_id)
+                && (leader_in_this_project || !item.view.is_project_item(window, cx))
+            {
+                item_to_activate = Some((item.location, item.view.boxed_clone()));
             }
         } else if let Some(shared_screen) =
             self.shared_screen_for_peer(peer_id, &state.center_pane, window, cx)
@@ -6079,10 +6069,10 @@ fn open_items(
             project_paths_to_open
                 .iter_mut()
                 .for_each(|(_, project_path)| {
-                    if let Some(project_path_to_open) = project_path {
-                        if restored_project_paths.contains(project_path_to_open) {
-                            *project_path = None;
-                        }
+                    if let Some(project_path_to_open) = project_path
+                        && restored_project_paths.contains(project_path_to_open)
+                    {
+                        *project_path = None;
                     }
                 });
         } else {
@@ -6109,24 +6099,24 @@ fn open_items(
                         // We only want to open file paths here. If one of the items
                         // here is a directory, it was already opened further above
                         // with a `find_or_create_worktree`.
-                        if let Ok(task) = abs_path_task {
-                            if task.await.map_or(true, |p| p.is_file()) {
-                                return Some((
-                                    ix,
-                                    workspace
-                                        .update_in(cx, |workspace, window, cx| {
-                                            workspace.open_path(
-                                                file_project_path,
-                                                None,
-                                                true,
-                                                window,
-                                                cx,
-                                            )
-                                        })
-                                        .log_err()?
-                                        .await,
-                                ));
-                            }
+                        if let Ok(task) = abs_path_task
+                            && task.await.map_or(true, |p| p.is_file())
+                        {
+                            return Some((
+                                ix,
+                                workspace
+                                    .update_in(cx, |workspace, window, cx| {
+                                        workspace.open_path(
+                                            file_project_path,
+                                            None,
+                                            true,
+                                            window,
+                                            cx,
+                                        )
+                                    })
+                                    .log_err()?
+                                    .await,
+                            ));
                         }
                         None
                     })
@@ -6728,10 +6718,10 @@ impl WorkspaceStore {
                     .update(cx, |workspace, window, cx| {
                         let handler_response =
                             workspace.handle_follow(follower.project_id, window, cx);
-                        if let Some(active_view) = handler_response.active_view.clone() {
-                            if workspace.project.read(cx).remote_id() == follower.project_id {
-                                response.active_view = Some(active_view)
-                            }
+                        if let Some(active_view) = handler_response.active_view.clone()
+                            && workspace.project.read(cx).remote_id() == follower.project_id
+                        {
+                            response.active_view = Some(active_view)
                         }
                     })
                     .is_ok()
@@ -6965,34 +6955,35 @@ async fn join_channel_internal(
         }
 
         // If you are the first to join a channel, see if you should share your project.
-        if room.remote_participants().is_empty() && !room.local_participant_is_guest() {
-            if let Some(workspace) = requesting_window {
-                let project = workspace.update(cx, |workspace, _, cx| {
-                    let project = workspace.project.read(cx);
+        if room.remote_participants().is_empty()
+            && !room.local_participant_is_guest()
+            && let Some(workspace) = requesting_window
+        {
+            let project = workspace.update(cx, |workspace, _, cx| {
+                let project = workspace.project.read(cx);
 
-                    if !CallSettings::get_global(cx).share_on_join {
-                        return None;
-                    }
+                if !CallSettings::get_global(cx).share_on_join {
+                    return None;
+                }
 
-                    if (project.is_local() || project.is_via_ssh())
-                        && project.visible_worktrees(cx).any(|tree| {
-                            tree.read(cx)
-                                .root_entry()
-                                .map_or(false, |entry| entry.is_dir())
-                        })
-                    {
-                        Some(workspace.project.clone())
-                    } else {
-                        None
-                    }
-                });
-                if let Ok(Some(project)) = project {
-                    return Some(cx.spawn(async move |room, cx| {
-                        room.update(cx, |room, cx| room.share_project(project, cx))?
-                            .await?;
-                        Ok(())
-                    }));
+                if (project.is_local() || project.is_via_ssh())
+                    && project.visible_worktrees(cx).any(|tree| {
+                        tree.read(cx)
+                            .root_entry()
+                            .map_or(false, |entry| entry.is_dir())
+                    })
+                {
+                    Some(workspace.project.clone())
+                } else {
+                    None
                 }
+            });
+            if let Ok(Some(project)) = project {
+                return Some(cx.spawn(async move |room, cx| {
+                    room.update(cx, |room, cx| room.share_project(project, cx))?
+                        .await?;
+                    Ok(())
+                }));
             }
         }
 
@@ -7189,35 +7180,35 @@ pub fn open_paths(
                 }
             })?;
 
-            if open_options.open_new_workspace.is_none() && existing.is_none() {
-                if all_metadatas.iter().all(|file| !file.is_dir) {
-                    cx.update(|cx| {
-                        if let Some(window) = cx
-                            .active_window()
-                            .and_then(|window| window.downcast::<Workspace>())
-                        {
-                            if let Ok(workspace) = window.read(cx) {
-                                let project = workspace.project().read(cx);
-                                if project.is_local() && !project.is_via_collab() {
-                                    existing = Some(window);
-                                    open_visible = OpenVisible::None;
-                                    return;
-                                }
-                            }
+            if open_options.open_new_workspace.is_none()
+                && existing.is_none()
+                && all_metadatas.iter().all(|file| !file.is_dir)
+            {
+                cx.update(|cx| {
+                    if let Some(window) = cx
+                        .active_window()
+                        .and_then(|window| window.downcast::<Workspace>())
+                        && let Ok(workspace) = window.read(cx)
+                    {
+                        let project = workspace.project().read(cx);
+                        if project.is_local() && !project.is_via_collab() {
+                            existing = Some(window);
+                            open_visible = OpenVisible::None;
+                            return;
                         }
-                        for window in local_workspace_windows(cx) {
-                            if let Ok(workspace) = window.read(cx) {
-                                let project = workspace.project().read(cx);
-                                if project.is_via_collab() {
-                                    continue;
-                                }
-                                existing = Some(window);
-                                open_visible = OpenVisible::None;
-                                break;
+                    }
+                    for window in local_workspace_windows(cx) {
+                        if let Ok(workspace) = window.read(cx) {
+                            let project = workspace.project().read(cx);
+                            if project.is_via_collab() {
+                                continue;
                             }
+                            existing = Some(window);
+                            open_visible = OpenVisible::None;
+                            break;
                         }
-                    })?;
-                }
+                    }
+                })?;
             }
         }
 
@@ -7651,10 +7642,9 @@ pub fn reload(cx: &mut App) {
         for window in workspace_windows {
             if let Ok(should_close) = window.update(cx, |workspace, window, cx| {
                 workspace.prepare_to_close(CloseIntent::Quit, window, cx)
-            }) {
-                if !should_close.await? {
-                    return Ok(());
-                }
+            }) && !should_close.await?
+            {
+                return Ok(());
             }
         }
         cx.update(|cx| cx.restart())

crates/workspace/src/workspace_settings.rs πŸ”—

@@ -282,19 +282,17 @@ impl Settings for WorkspaceSettings {
         if vscode
             .read_bool("accessibility.dimUnfocused.enabled")
             .unwrap_or_default()
-        {
-            if let Some(opacity) = vscode
+            && let Some(opacity) = vscode
                 .read_value("accessibility.dimUnfocused.opacity")
                 .and_then(|v| v.as_f64())
-            {
-                if let Some(settings) = current.active_pane_modifiers.as_mut() {
-                    settings.inactive_opacity = Some(opacity as f32)
-                } else {
-                    current.active_pane_modifiers = Some(ActivePanelModifiers {
-                        inactive_opacity: Some(opacity as f32),
-                        ..Default::default()
-                    })
-                }
+        {
+            if let Some(settings) = current.active_pane_modifiers.as_mut() {
+                settings.inactive_opacity = Some(opacity as f32)
+            } else {
+                current.active_pane_modifiers = Some(ActivePanelModifiers {
+                    inactive_opacity: Some(opacity as f32),
+                    ..Default::default()
+                })
             }
         }
 
@@ -345,13 +343,11 @@ impl Settings for WorkspaceSettings {
             .read_value("workbench.editor.limit.value")
             .and_then(|v| v.as_u64())
             .and_then(|n| NonZeroUsize::new(n as usize))
-        {
-            if vscode
+            && vscode
                 .read_bool("workbench.editor.limit.enabled")
                 .unwrap_or_default()
-            {
-                current.max_tabs = Some(n)
-            }
+        {
+            current.max_tabs = Some(n)
         }
 
         // some combination of "window.restoreWindows" and "workbench.startupEditor" might

crates/worktree/src/worktree.rs πŸ”—

@@ -1522,10 +1522,10 @@ impl LocalWorktree {
             //       reasonable limit
             {
                 const FILE_SIZE_MAX: u64 = 6 * 1024 * 1024 * 1024; // 6GB
-                if let Ok(Some(metadata)) = fs.metadata(&abs_path).await {
-                    if metadata.len >= FILE_SIZE_MAX {
-                        anyhow::bail!("File is too large to load");
-                    }
+                if let Ok(Some(metadata)) = fs.metadata(&abs_path).await
+                    && metadata.len >= FILE_SIZE_MAX
+                {
+                    anyhow::bail!("File is too large to load");
                 }
             }
             let text = fs.load(&abs_path).await?;
@@ -2503,10 +2503,10 @@ impl Snapshot {
             if let Some(PathEntry { path, .. }) = self.entries_by_id.get(&entry.id, &()) {
                 entries_by_path_edits.push(Edit::Remove(PathKey(path.clone())));
             }
-            if let Some(old_entry) = self.entries_by_path.get(&PathKey(entry.path.clone()), &()) {
-                if old_entry.id != entry.id {
-                    entries_by_id_edits.push(Edit::Remove(old_entry.id));
-                }
+            if let Some(old_entry) = self.entries_by_path.get(&PathKey(entry.path.clone()), &())
+                && old_entry.id != entry.id
+            {
+                entries_by_id_edits.push(Edit::Remove(old_entry.id));
             }
             entries_by_id_edits.push(Edit::Insert(PathEntry {
                 id: entry.id,
@@ -2747,20 +2747,19 @@ impl LocalSnapshot {
             }
         }
 
-        if entry.kind == EntryKind::PendingDir {
-            if let Some(existing_entry) =
+        if entry.kind == EntryKind::PendingDir
+            && let Some(existing_entry) =
                 self.entries_by_path.get(&PathKey(entry.path.clone()), &())
-            {
-                entry.kind = existing_entry.kind;
-            }
+        {
+            entry.kind = existing_entry.kind;
         }
 
         let scan_id = self.scan_id;
         let removed = self.entries_by_path.insert_or_replace(entry.clone(), &());
-        if let Some(removed) = removed {
-            if removed.id != entry.id {
-                self.entries_by_id.remove(&removed.id, &());
-            }
+        if let Some(removed) = removed
+            && removed.id != entry.id
+        {
+            self.entries_by_id.remove(&removed.id, &());
         }
         self.entries_by_id.insert_or_replace(
             PathEntry {
@@ -4138,13 +4137,13 @@ impl BackgroundScanner {
             let root_path = state.snapshot.abs_path.clone();
             for path in paths {
                 for ancestor in path.ancestors() {
-                    if let Some(entry) = state.snapshot.entry_for_path(ancestor) {
-                        if entry.kind == EntryKind::UnloadedDir {
-                            let abs_path = root_path.as_path().join(ancestor);
-                            state.enqueue_scan_dir(abs_path.into(), entry, &scan_job_tx);
-                            state.paths_to_scan.insert(path.clone());
-                            break;
-                        }
+                    if let Some(entry) = state.snapshot.entry_for_path(ancestor)
+                        && entry.kind == EntryKind::UnloadedDir
+                    {
+                        let abs_path = root_path.as_path().join(ancestor);
+                        state.enqueue_scan_dir(abs_path.into(), entry, &scan_job_tx);
+                        state.paths_to_scan.insert(path.clone());
+                        break;
                     }
                 }
             }
@@ -4214,11 +4213,10 @@ impl BackgroundScanner {
                                 // Recursively load directories from the file system.
                                 job = scan_jobs_rx.recv().fuse() => {
                                     let Ok(job) = job else { break };
-                                    if let Err(err) = self.scan_dir(&job).await {
-                                        if job.path.as_ref() != Path::new("") {
+                                    if let Err(err) = self.scan_dir(&job).await
+                                        && job.path.as_ref() != Path::new("") {
                                             log::error!("error scanning directory {:?}: {}", job.abs_path, err);
                                         }
-                                    }
                                 }
                             }
                         }
@@ -4554,18 +4552,18 @@ impl BackgroundScanner {
 
                     state.insert_entry(fs_entry.clone(), self.fs.as_ref(), self.watcher.as_ref());
 
-                    if path.as_ref() == Path::new("") {
-                        if let Some((ignores, repo)) = new_ancestor_repo.take() {
-                            log::trace!("updating ancestor git repository");
-                            state.snapshot.ignores_by_parent_abs_path.extend(ignores);
-                            if let Some((ancestor_dot_git, work_directory)) = repo {
-                                state.insert_git_repository_for_path(
-                                    work_directory,
-                                    ancestor_dot_git.as_path().into(),
-                                    self.fs.as_ref(),
-                                    self.watcher.as_ref(),
-                                );
-                            }
+                    if path.as_ref() == Path::new("")
+                        && let Some((ignores, repo)) = new_ancestor_repo.take()
+                    {
+                        log::trace!("updating ancestor git repository");
+                        state.snapshot.ignores_by_parent_abs_path.extend(ignores);
+                        if let Some((ancestor_dot_git, work_directory)) = repo {
+                            state.insert_git_repository_for_path(
+                                work_directory,
+                                ancestor_dot_git.as_path().into(),
+                                self.fs.as_ref(),
+                                self.watcher.as_ref(),
+                            );
                         }
                     }
                 }
@@ -4590,13 +4588,12 @@ impl BackgroundScanner {
         if !path
             .components()
             .any(|component| component.as_os_str() == *DOT_GIT)
+            && let Some(local_repo) = snapshot.local_repo_for_work_directory_path(path)
         {
-            if let Some(local_repo) = snapshot.local_repo_for_work_directory_path(path) {
-                let id = local_repo.work_directory_id;
-                log::debug!("remove repo path: {:?}", path);
-                snapshot.git_repositories.remove(&id);
-                return Some(());
-            }
+            let id = local_repo.work_directory_id;
+            log::debug!("remove repo path: {:?}", path);
+            snapshot.git_repositories.remove(&id);
+            return Some(());
         }
 
         Some(())
@@ -4738,10 +4735,10 @@ impl BackgroundScanner {
 
         let state = &mut self.state.lock();
         for edit in &entries_by_path_edits {
-            if let Edit::Insert(entry) = edit {
-                if let Err(ix) = state.changed_paths.binary_search(&entry.path) {
-                    state.changed_paths.insert(ix, entry.path.clone());
-                }
+            if let Edit::Insert(entry) = edit
+                && let Err(ix) = state.changed_paths.binary_search(&entry.path)
+            {
+                state.changed_paths.insert(ix, entry.path.clone());
             }
         }
 
@@ -5287,13 +5284,12 @@ impl<'a> Traversal<'a> {
         while let Some(entry) = self.cursor.item() {
             self.cursor
                 .seek_forward(&TraversalTarget::successor(&entry.path), Bias::Left);
-            if let Some(entry) = self.cursor.item() {
-                if (self.include_files || !entry.is_file())
-                    && (self.include_dirs || !entry.is_dir())
-                    && (self.include_ignored || !entry.is_ignored || entry.is_always_included)
-                {
-                    return true;
-                }
+            if let Some(entry) = self.cursor.item()
+                && (self.include_files || !entry.is_file())
+                && (self.include_dirs || !entry.is_dir())
+                && (self.include_ignored || !entry.is_ignored || entry.is_always_included)
+            {
+                return true;
             }
         }
         false
@@ -5437,11 +5433,11 @@ impl<'a> Iterator for ChildEntriesIter<'a> {
     type Item = &'a Entry;
 
     fn next(&mut self) -> Option<Self::Item> {
-        if let Some(item) = self.traversal.entry() {
-            if item.path.starts_with(self.parent_path) {
-                self.traversal.advance_to_sibling();
-                return Some(item);
-            }
+        if let Some(item) = self.traversal.entry()
+            && item.path.starts_with(self.parent_path)
+        {
+            self.traversal.advance_to_sibling();
+            return Some(item);
         }
         None
     }
@@ -5564,12 +5560,10 @@ fn discover_git_paths(dot_git_abs_path: &Arc<Path>, fs: &dyn Fs) -> (Arc<Path>,
             repository_dir_abs_path = Path::new(&path).into();
             common_dir_abs_path = repository_dir_abs_path.clone();
             if let Some(commondir_contents) = smol::block_on(fs.load(&path.join("commondir"))).ok()
-            {
-                if let Some(commondir_path) =
+                && let Some(commondir_path) =
                     smol::block_on(fs.canonicalize(&path.join(commondir_contents.trim()))).log_err()
-                {
-                    common_dir_abs_path = commondir_path.as_path().into();
-                }
+            {
+                common_dir_abs_path = commondir_path.as_path().into();
             }
         }
     };

crates/zed/build.rs πŸ”—

@@ -23,22 +23,20 @@ fn main() {
         "cargo:rustc-env=TARGET={}",
         std::env::var("TARGET").unwrap()
     );
-    if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() {
-        if output.status.success() {
-            let git_sha = String::from_utf8_lossy(&output.stdout);
-            let git_sha = git_sha.trim();
+    if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output()
+        && output.status.success()
+    {
+        let git_sha = String::from_utf8_lossy(&output.stdout);
+        let git_sha = git_sha.trim();
 
-            println!("cargo:rustc-env=ZED_COMMIT_SHA={git_sha}");
+        println!("cargo:rustc-env=ZED_COMMIT_SHA={git_sha}");
 
-            if let Ok(build_profile) = std::env::var("PROFILE") {
-                if build_profile == "release" {
-                    // This is currently the best way to make `cargo build ...`'s build script
-                    // to print something to stdout without extra verbosity.
-                    println!(
-                        "cargo:warning=Info: using '{git_sha}' hash for ZED_COMMIT_SHA env var"
-                    );
-                }
-            }
+        if let Ok(build_profile) = std::env::var("PROFILE")
+            && build_profile == "release"
+        {
+            // This is currently the best way to make `cargo build ...`'s build script
+            // to print something to stdout without extra verbosity.
+            println!("cargo:warning=Info: using '{git_sha}' hash for ZED_COMMIT_SHA env var");
         }
     }
 

crates/zed/src/main.rs πŸ”—

@@ -1026,18 +1026,18 @@ async fn restore_or_create_workspace(app_state: Arc<AppState>, cx: &mut AsyncApp
             // Try to find an active workspace to show the toast
             let toast_shown = cx
                 .update(|cx| {
-                    if let Some(window) = cx.active_window() {
-                        if let Some(workspace) = window.downcast::<Workspace>() {
-                            workspace
-                                .update(cx, |workspace, _, cx| {
-                                    workspace.show_toast(
-                                        Toast::new(NotificationId::unique::<()>(), message),
-                                        cx,
-                                    )
-                                })
-                                .ok();
-                            return true;
-                        }
+                    if let Some(window) = cx.active_window()
+                        && let Some(workspace) = window.downcast::<Workspace>()
+                    {
+                        workspace
+                            .update(cx, |workspace, _, cx| {
+                                workspace.show_toast(
+                                    Toast::new(NotificationId::unique::<()>(), message),
+                                    cx,
+                                )
+                            })
+                            .ok();
+                        return true;
                     }
                     false
                 })
@@ -1117,10 +1117,8 @@ pub(crate) async fn restorable_workspace_locations(
 
                 // Since last_session_window_order returns the windows ordered front-to-back
                 // we need to open the window that was frontmost last.
-                if ordered {
-                    if let Some(locations) = locations.as_mut() {
-                        locations.reverse();
-                    }
+                if ordered && let Some(locations) = locations.as_mut() {
+                    locations.reverse();
                 }
 
                 locations
@@ -1290,21 +1288,21 @@ fn eager_load_active_theme_and_icon_theme(fs: Arc<dyn Fs>, cx: &App) {
 
     if let Some(theme_selection) = theme_settings.theme_selection.as_ref() {
         let theme_name = theme_selection.theme(appearance);
-        if matches!(theme_registry.get(theme_name), Err(ThemeNotFoundError(_))) {
-            if let Some(theme_path) = extension_store.read(cx).path_to_extension_theme(theme_name) {
-                cx.spawn({
-                    let theme_registry = theme_registry.clone();
-                    let fs = fs.clone();
-                    async move |cx| {
-                        theme_registry.load_user_theme(&theme_path, fs).await?;
+        if matches!(theme_registry.get(theme_name), Err(ThemeNotFoundError(_)))
+            && let Some(theme_path) = extension_store.read(cx).path_to_extension_theme(theme_name)
+        {
+            cx.spawn({
+                let theme_registry = theme_registry.clone();
+                let fs = fs.clone();
+                async move |cx| {
+                    theme_registry.load_user_theme(&theme_path, fs).await?;
 
-                        cx.update(|cx| {
-                            ThemeSettings::reload_current_theme(cx);
-                        })
-                    }
-                })
-                .detach_and_log_err(cx);
-            }
+                    cx.update(|cx| {
+                        ThemeSettings::reload_current_theme(cx);
+                    })
+                }
+            })
+            .detach_and_log_err(cx);
         }
     }
 
@@ -1313,26 +1311,24 @@ fn eager_load_active_theme_and_icon_theme(fs: Arc<dyn Fs>, cx: &App) {
         if matches!(
             theme_registry.get_icon_theme(icon_theme_name),
             Err(IconThemeNotFoundError(_))
-        ) {
-            if let Some((icon_theme_path, icons_root_path)) = extension_store
-                .read(cx)
-                .path_to_extension_icon_theme(icon_theme_name)
-            {
-                cx.spawn({
-                    let theme_registry = theme_registry.clone();
-                    let fs = fs.clone();
-                    async move |cx| {
-                        theme_registry
-                            .load_icon_theme(&icon_theme_path, &icons_root_path, fs)
-                            .await?;
+        ) && let Some((icon_theme_path, icons_root_path)) = extension_store
+            .read(cx)
+            .path_to_extension_icon_theme(icon_theme_name)
+        {
+            cx.spawn({
+                let theme_registry = theme_registry.clone();
+                let fs = fs.clone();
+                async move |cx| {
+                    theme_registry
+                        .load_icon_theme(&icon_theme_path, &icons_root_path, fs)
+                        .await?;
 
-                        cx.update(|cx| {
-                            ThemeSettings::reload_current_icon_theme(cx);
-                        })
-                    }
-                })
-                .detach_and_log_err(cx);
-            }
+                    cx.update(|cx| {
+                        ThemeSettings::reload_current_icon_theme(cx);
+                    })
+                }
+            })
+            .detach_and_log_err(cx);
         }
     }
 }
@@ -1381,18 +1377,15 @@ fn watch_themes(fs: Arc<dyn fs::Fs>, cx: &mut App) {
 
         while let Some(paths) = events.next().await {
             for event in paths {
-                if fs.metadata(&event.path).await.ok().flatten().is_some() {
-                    if let Some(theme_registry) =
+                if fs.metadata(&event.path).await.ok().flatten().is_some()
+                    && let Some(theme_registry) =
                         cx.update(|cx| ThemeRegistry::global(cx).clone()).log_err()
-                    {
-                        if let Some(()) = theme_registry
-                            .load_user_theme(&event.path, fs.clone())
-                            .await
-                            .log_err()
-                        {
-                            cx.update(ThemeSettings::reload_current_theme).log_err();
-                        }
-                    }
+                    && let Some(()) = theme_registry
+                        .load_user_theme(&event.path, fs.clone())
+                        .await
+                        .log_err()
+                {
+                    cx.update(ThemeSettings::reload_current_theme).log_err();
                 }
             }
         }

crates/zed/src/reliability.rs πŸ”—

@@ -146,19 +146,17 @@ pub fn init_panic_hook(
         }
         zlog::flush();
 
-        if !is_pty {
-            if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
-                let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
-                let panic_file_path = paths::logs_dir().join(format!("zed-{timestamp}.panic"));
-                let panic_file = fs::OpenOptions::new()
-                    .write(true)
-                    .create_new(true)
-                    .open(&panic_file_path)
-                    .log_err();
-                if let Some(mut panic_file) = panic_file {
-                    writeln!(&mut panic_file, "{panic_data_json}").log_err();
-                    panic_file.flush().log_err();
-                }
+        if !is_pty && let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
+            let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
+            let panic_file_path = paths::logs_dir().join(format!("zed-{timestamp}.panic"));
+            let panic_file = fs::OpenOptions::new()
+                .write(true)
+                .create_new(true)
+                .open(&panic_file_path)
+                .log_err();
+            if let Some(mut panic_file) = panic_file {
+                writeln!(&mut panic_file, "{panic_data_json}").log_err();
+                panic_file.flush().log_err();
             }
         }
 
@@ -459,10 +457,10 @@ pub fn monitor_main_thread_hangs(
                         continue;
                     };
 
-                    if let Some(response) = http_client.send(request).await.log_err() {
-                        if response.status() != 200 {
-                            log::error!("Failed to send hang report: HTTP {:?}", response.status());
-                        }
+                    if let Some(response) = http_client.send(request).await.log_err()
+                        && response.status() != 200
+                    {
+                        log::error!("Failed to send hang report: HTTP {:?}", response.status());
                     }
                 }
             }
@@ -563,8 +561,8 @@ pub async fn upload_previous_minidumps(http: Arc<HttpClientWithUrl>) -> anyhow::
         }
         let mut json_path = child_path.clone();
         json_path.set_extension("json");
-        if let Ok(metadata) = serde_json::from_slice(&smol::fs::read(&json_path).await?) {
-            if upload_minidump(
+        if let Ok(metadata) = serde_json::from_slice(&smol::fs::read(&json_path).await?)
+            && upload_minidump(
                 http.clone(),
                 minidump_endpoint,
                 smol::fs::read(&child_path)
@@ -575,10 +573,9 @@ pub async fn upload_previous_minidumps(http: Arc<HttpClientWithUrl>) -> anyhow::
             .await
             .log_err()
             .is_some()
-            {
-                fs::remove_file(child_path).ok();
-                fs::remove_file(json_path).ok();
-            }
+        {
+            fs::remove_file(child_path).ok();
+            fs::remove_file(json_path).ok();
         }
     }
     Ok(())

crates/zed/src/zed.rs πŸ”—

@@ -1054,27 +1054,25 @@ fn quit(_: &Quit, cx: &mut App) {
         })
         .log_err();
 
-        if should_confirm {
-            if let Some(workspace) = workspace_windows.first() {
-                let answer = workspace
-                    .update(cx, |_, window, cx| {
-                        window.prompt(
-                            PromptLevel::Info,
-                            "Are you sure you want to quit?",
-                            None,
-                            &["Quit", "Cancel"],
-                            cx,
-                        )
-                    })
-                    .log_err();
+        if should_confirm && let Some(workspace) = workspace_windows.first() {
+            let answer = workspace
+                .update(cx, |_, window, cx| {
+                    window.prompt(
+                        PromptLevel::Info,
+                        "Are you sure you want to quit?",
+                        None,
+                        &["Quit", "Cancel"],
+                        cx,
+                    )
+                })
+                .log_err();
 
-                if let Some(answer) = answer {
-                    WAITING_QUIT_CONFIRMATION.store(true, atomic::Ordering::Release);
-                    let answer = answer.await.ok();
-                    WAITING_QUIT_CONFIRMATION.store(false, atomic::Ordering::Release);
-                    if answer != Some(0) {
-                        return Ok(());
-                    }
+            if let Some(answer) = answer {
+                WAITING_QUIT_CONFIRMATION.store(true, atomic::Ordering::Release);
+                let answer = answer.await.ok();
+                WAITING_QUIT_CONFIRMATION.store(false, atomic::Ordering::Release);
+                if answer != Some(0) {
+                    return Ok(());
                 }
             }
         }
@@ -1086,10 +1084,9 @@ fn quit(_: &Quit, cx: &mut App) {
                     workspace.prepare_to_close(CloseIntent::Quit, window, cx)
                 })
                 .log_err()
+                && !should_close.await?
             {
-                if !should_close.await? {
-                    return Ok(());
-                }
+                return Ok(());
             }
         }
         cx.update(|cx| cx.quit())?;
@@ -1633,15 +1630,15 @@ fn open_local_file(
             };
 
             if !file_exists {
-                if let Some(dir_path) = settings_relative_path.parent() {
-                    if worktree.read_with(cx, |tree, _| tree.entry_for_path(dir_path).is_none())? {
-                        project
-                            .update(cx, |project, cx| {
-                                project.create_entry((tree_id, dir_path), true, cx)
-                            })?
-                            .await
-                            .context("worktree was removed")?;
-                    }
+                if let Some(dir_path) = settings_relative_path.parent()
+                    && worktree.read_with(cx, |tree, _| tree.entry_for_path(dir_path).is_none())?
+                {
+                    project
+                        .update(cx, |project, cx| {
+                            project.create_entry((tree_id, dir_path), true, cx)
+                        })?
+                        .await
+                        .context("worktree was removed")?;
                 }
 
                 if worktree.read_with(cx, |tree, _| {
@@ -1667,12 +1664,12 @@ fn open_local_file(
             editor
                 .downgrade()
                 .update(cx, |editor, cx| {
-                    if let Some(buffer) = editor.buffer().read(cx).as_singleton() {
-                        if buffer.read(cx).is_empty() {
-                            buffer.update(cx, |buffer, cx| {
-                                buffer.edit([(0..0, initial_contents)], None, cx)
-                            });
-                        }
+                    if let Some(buffer) = editor.buffer().read(cx).as_singleton()
+                        && buffer.read(cx).is_empty()
+                    {
+                        buffer.update(cx, |buffer, cx| {
+                            buffer.edit([(0..0, initial_contents)], None, cx)
+                        });
                     }
                 })
                 .ok();

crates/zed/src/zed/component_preview.rs πŸ”—

@@ -318,26 +318,26 @@ impl ComponentPreview {
             let lowercase_scope = scope_name.to_lowercase();
             let lowercase_desc = description.to_lowercase();
 
-            if lowercase_scopeless.contains(&lowercase_filter) {
-                if let Some(index) = lowercase_scopeless.find(&lowercase_filter) {
-                    let end = index + lowercase_filter.len();
-
-                    if end <= scopeless_name.len() {
-                        let mut positions = Vec::new();
-                        for i in index..end {
-                            if scopeless_name.is_char_boundary(i) {
-                                positions.push(i);
-                            }
-                        }
+            if lowercase_scopeless.contains(&lowercase_filter)
+                && let Some(index) = lowercase_scopeless.find(&lowercase_filter)
+            {
+                let end = index + lowercase_filter.len();
 
-                        if !positions.is_empty() {
-                            scope_groups
-                                .entry(component.scope())
-                                .or_insert_with(Vec::new)
-                                .push((component.clone(), Some(positions)));
-                            continue;
+                if end <= scopeless_name.len() {
+                    let mut positions = Vec::new();
+                    for i in index..end {
+                        if scopeless_name.is_char_boundary(i) {
+                            positions.push(i);
                         }
                     }
+
+                    if !positions.is_empty() {
+                        scope_groups
+                            .entry(component.scope())
+                            .or_insert_with(Vec::new)
+                            .push((component.clone(), Some(positions)));
+                        continue;
+                    }
                 }
             }
 
@@ -372,32 +372,32 @@ impl ComponentPreview {
         scopes.sort_by_key(|s| s.to_string());
 
         for scope in scopes {
-            if let Some(components) = scope_groups.remove(&scope) {
-                if !components.is_empty() {
-                    entries.push(PreviewEntry::Separator);
-                    entries.push(PreviewEntry::SectionHeader(scope.to_string().into()));
+            if let Some(components) = scope_groups.remove(&scope)
+                && !components.is_empty()
+            {
+                entries.push(PreviewEntry::Separator);
+                entries.push(PreviewEntry::SectionHeader(scope.to_string().into()));
 
-                    let mut sorted_components = components;
-                    sorted_components.sort_by_key(|(component, _)| component.sort_name());
+                let mut sorted_components = components;
+                sorted_components.sort_by_key(|(component, _)| component.sort_name());
 
-                    for (component, positions) in sorted_components {
-                        entries.push(PreviewEntry::Component(component, positions));
-                    }
+                for (component, positions) in sorted_components {
+                    entries.push(PreviewEntry::Component(component, positions));
                 }
             }
         }
 
         // Add uncategorized components last
-        if let Some(components) = scope_groups.get(&ComponentScope::None) {
-            if !components.is_empty() {
-                entries.push(PreviewEntry::Separator);
-                entries.push(PreviewEntry::SectionHeader("Uncategorized".into()));
-                let mut sorted_components = components.clone();
-                sorted_components.sort_by_key(|(c, _)| c.sort_name());
-
-                for (component, positions) in sorted_components {
-                    entries.push(PreviewEntry::Component(component, positions));
-                }
+        if let Some(components) = scope_groups.get(&ComponentScope::None)
+            && !components.is_empty()
+        {
+            entries.push(PreviewEntry::Separator);
+            entries.push(PreviewEntry::SectionHeader("Uncategorized".into()));
+            let mut sorted_components = components.clone();
+            sorted_components.sort_by_key(|(c, _)| c.sort_name());
+
+            for (component, positions) in sorted_components {
+                entries.push(PreviewEntry::Component(component, positions));
             }
         }
 
@@ -415,19 +415,20 @@ impl ComponentPreview {
 
         let filtered_components = self.filtered_components();
 
-        if !self.filter_text.is_empty() && !matches!(self.active_page, PreviewPage::AllComponents) {
-            if let PreviewPage::Component(ref component_id) = self.active_page {
-                let component_still_visible = filtered_components
-                    .iter()
-                    .any(|component| component.id() == *component_id);
-
-                if !component_still_visible {
-                    if !filtered_components.is_empty() {
-                        let first_component = &filtered_components[0];
-                        self.set_active_page(PreviewPage::Component(first_component.id()), cx);
-                    } else {
-                        self.set_active_page(PreviewPage::AllComponents, cx);
-                    }
+        if !self.filter_text.is_empty()
+            && !matches!(self.active_page, PreviewPage::AllComponents)
+            && let PreviewPage::Component(ref component_id) = self.active_page
+        {
+            let component_still_visible = filtered_components
+                .iter()
+                .any(|component| component.id() == *component_id);
+
+            if !component_still_visible {
+                if !filtered_components.is_empty() {
+                    let first_component = &filtered_components[0];
+                    self.set_active_page(PreviewPage::Component(first_component.id()), cx);
+                } else {
+                    self.set_active_page(PreviewPage::AllComponents, cx);
                 }
             }
         }

crates/zed/src/zed/edit_prediction_registry.rs πŸ”—

@@ -204,12 +204,12 @@ fn assign_edit_prediction_provider(
         }
         EditPredictionProvider::Copilot => {
             if let Some(copilot) = Copilot::global(cx) {
-                if let Some(buffer) = singleton_buffer {
-                    if buffer.read(cx).file().is_some() {
-                        copilot.update(cx, |copilot, cx| {
-                            copilot.register_buffer(&buffer, cx);
-                        });
-                    }
+                if let Some(buffer) = singleton_buffer
+                    && buffer.read(cx).file().is_some()
+                {
+                    copilot.update(cx, |copilot, cx| {
+                        copilot.register_buffer(&buffer, cx);
+                    });
                 }
                 let provider = cx.new(|_| CopilotCompletionProvider::new(copilot));
                 editor.set_edit_prediction_provider(Some(provider), window, cx);
@@ -225,15 +225,15 @@ fn assign_edit_prediction_provider(
             if user_store.read(cx).current_user().is_some() {
                 let mut worktree = None;
 
-                if let Some(buffer) = &singleton_buffer {
-                    if let Some(file) = buffer.read(cx).file() {
-                        let id = file.worktree_id(cx);
-                        if let Some(inner_worktree) = editor
-                            .project()
-                            .and_then(|project| project.read(cx).worktree_for_id(id, cx))
-                        {
-                            worktree = Some(inner_worktree);
-                        }
+                if let Some(buffer) = &singleton_buffer
+                    && let Some(file) = buffer.read(cx).file()
+                {
+                    let id = file.worktree_id(cx);
+                    if let Some(inner_worktree) = editor
+                        .project()
+                        .and_then(|project| project.read(cx).worktree_for_id(id, cx))
+                    {
+                        worktree = Some(inner_worktree);
                     }
                 }
 
@@ -245,12 +245,12 @@ fn assign_edit_prediction_provider(
                 let zeta =
                     zeta::Zeta::register(workspace, worktree, client.clone(), user_store, cx);
 
-                if let Some(buffer) = &singleton_buffer {
-                    if buffer.read(cx).file().is_some() {
-                        zeta.update(cx, |zeta, cx| {
-                            zeta.register_buffer(buffer, cx);
-                        });
-                    }
+                if let Some(buffer) = &singleton_buffer
+                    && buffer.read(cx).file().is_some()
+                {
+                    zeta.update(cx, |zeta, cx| {
+                        zeta.register_buffer(buffer, cx);
+                    });
                 }
 
                 let data_collection =

crates/zed/src/zed/mac_only_instance.rs πŸ”—

@@ -37,20 +37,19 @@ fn address() -> SocketAddr {
     let mut user_port = port;
     let mut sys = System::new_all();
     sys.refresh_all();
-    if let Ok(current_pid) = sysinfo::get_current_pid() {
-        if let Some(uid) = sys
+    if let Ok(current_pid) = sysinfo::get_current_pid()
+        && let Some(uid) = sys
             .process(current_pid)
             .and_then(|process| process.user_id())
-        {
-            let uid_u32 = get_uid_as_u32(uid);
-            // Ensure that the user ID is not too large to avoid overflow when
-            // calculating the port number. This seems unlikely but it doesn't
-            // hurt to be safe.
-            let max_port = 65535;
-            let max_uid: u32 = max_port - port as u32;
-            let wrapped_uid: u16 = (uid_u32 % max_uid) as u16;
-            user_port += wrapped_uid;
-        }
+    {
+        let uid_u32 = get_uid_as_u32(uid);
+        // Ensure that the user ID is not too large to avoid overflow when
+        // calculating the port number. This seems unlikely but it doesn't
+        // hurt to be safe.
+        let max_port = 65535;
+        let max_uid: u32 = max_port - port as u32;
+        let wrapped_uid: u16 = (uid_u32 % max_uid) as u16;
+        user_port += wrapped_uid;
     }
 
     SocketAddr::V4(SocketAddrV4::new(LOCALHOST, user_port))

crates/zed/src/zed/open_listener.rs πŸ”—

@@ -123,26 +123,24 @@ impl OpenRequest {
 
     fn parse_request_path(&mut self, request_path: &str) -> Result<()> {
         let mut parts = request_path.split('/');
-        if parts.next() == Some("channel") {
-            if let Some(slug) = parts.next() {
-                if let Some(id_str) = slug.split('-').next_back() {
-                    if let Ok(channel_id) = id_str.parse::<u64>() {
-                        let Some(next) = parts.next() else {
-                            self.join_channel = Some(channel_id);
-                            return Ok(());
-                        };
-
-                        if let Some(heading) = next.strip_prefix("notes#") {
-                            self.open_channel_notes
-                                .push((channel_id, Some(heading.to_string())));
-                            return Ok(());
-                        }
-                        if next == "notes" {
-                            self.open_channel_notes.push((channel_id, None));
-                            return Ok(());
-                        }
-                    }
-                }
+        if parts.next() == Some("channel")
+            && let Some(slug) = parts.next()
+            && let Some(id_str) = slug.split('-').next_back()
+            && let Ok(channel_id) = id_str.parse::<u64>()
+        {
+            let Some(next) = parts.next() else {
+                self.join_channel = Some(channel_id);
+                return Ok(());
+            };
+
+            if let Some(heading) = next.strip_prefix("notes#") {
+                self.open_channel_notes
+                    .push((channel_id, Some(heading.to_string())));
+                return Ok(());
+            }
+            if next == "notes" {
+                self.open_channel_notes.push((channel_id, None));
+                return Ok(());
             }
         }
         anyhow::bail!("invalid zed url: {request_path}")
@@ -181,10 +179,10 @@ pub fn listen_for_cli_connections(opener: OpenListener) -> Result<()> {
 
     let sock_path = paths::data_dir().join(format!("zed-{}.sock", *RELEASE_CHANNEL_NAME));
     // remove the socket if the process listening on it has died
-    if let Err(e) = UnixDatagram::unbound()?.connect(&sock_path) {
-        if e.kind() == std::io::ErrorKind::ConnectionRefused {
-            std::fs::remove_file(&sock_path)?;
-        }
+    if let Err(e) = UnixDatagram::unbound()?.connect(&sock_path)
+        && e.kind() == std::io::ErrorKind::ConnectionRefused
+    {
+        std::fs::remove_file(&sock_path)?;
     }
     let listener = UnixDatagram::bind(&sock_path)?;
     thread::spawn(move || {
@@ -244,12 +242,12 @@ pub async fn open_paths_with_positions(
         .iter()
         .map(|path_with_position| {
             let path = path_with_position.path.clone();
-            if let Some(row) = path_with_position.row {
-                if path.is_file() {
-                    let row = row.saturating_sub(1);
-                    let col = path_with_position.column.unwrap_or(0).saturating_sub(1);
-                    caret_positions.insert(path.clone(), Point::new(row, col));
-                }
+            if let Some(row) = path_with_position.row
+                && path.is_file()
+            {
+                let row = row.saturating_sub(1);
+                let col = path_with_position.column.unwrap_or(0).saturating_sub(1);
+                caret_positions.insert(path.clone(), Point::new(row, col));
             }
             path
         })
@@ -264,10 +262,9 @@ pub async fn open_paths_with_positions(
         let new_path = Path::new(&diff_pair[1]).canonicalize()?;
         if let Ok(diff_view) = workspace.update(cx, |workspace, window, cx| {
             FileDiffView::open(old_path, new_path, workspace, window, cx)
-        }) {
-            if let Some(diff_view) = diff_view.await.log_err() {
-                items.push(Some(Ok(Box::new(diff_view))))
-            }
+        }) && let Some(diff_view) = diff_view.await.log_err()
+        {
+            items.push(Some(Ok(Box::new(diff_view))))
         }
     }
 

crates/zeta/src/rate_completion_modal.rs πŸ”—

@@ -267,13 +267,13 @@ impl RateCompletionModal {
                 .unwrap_or(self.selected_index);
             cx.notify();
 
-            if let Some(prev_completion) = self.active_completion.as_ref() {
-                if completion.id == prev_completion.completion.id {
-                    if focus {
-                        window.focus(&prev_completion.feedback_editor.focus_handle(cx));
-                    }
-                    return;
+            if let Some(prev_completion) = self.active_completion.as_ref()
+                && completion.id == prev_completion.completion.id
+            {
+                if focus {
+                    window.focus(&prev_completion.feedback_editor.focus_handle(cx));
                 }
+                return;
             }
         }
 

crates/zeta/src/zeta.rs πŸ”—

@@ -836,12 +836,11 @@ and then another
                 .headers()
                 .get(MINIMUM_REQUIRED_VERSION_HEADER_NAME)
                 .and_then(|version| SemanticVersion::from_str(version.to_str().ok()?).ok())
+                && app_version < minimum_required_version
             {
-                if app_version < minimum_required_version {
-                    return Err(anyhow!(ZedUpdateRequiredError {
-                        minimum_version: minimum_required_version
-                    }));
-                }
+                return Err(anyhow!(ZedUpdateRequiredError {
+                    minimum_version: minimum_required_version
+                }));
             }
 
             if response.status().is_success() {

crates/zlog/src/sink.rs πŸ”—

@@ -194,10 +194,10 @@ pub fn flush() {
         ENABLED_SINKS_FILE.clear_poison();
         handle.into_inner()
     });
-    if let Some(file) = file.as_mut() {
-        if let Err(err) = file.flush() {
-            eprintln!("Failed to flush log file: {}", err);
-        }
+    if let Some(file) = file.as_mut()
+        && let Err(err) = file.flush()
+    {
+        eprintln!("Failed to flush log file: {}", err);
     }
 }
 

crates/zlog/src/zlog.rs πŸ”—

@@ -28,10 +28,8 @@ pub fn try_init() -> anyhow::Result<()> {
 }
 
 pub fn init_test() {
-    if get_env_config().is_some() {
-        if try_init().is_ok() {
-            init_output_stdout();
-        }
+    if get_env_config().is_some() && try_init().is_ok() {
+        init_output_stdout();
     }
 }
 
@@ -344,18 +342,18 @@ impl Timer {
             return;
         }
         let elapsed = self.start_time.elapsed();
-        if let Some(warn_limit) = self.warn_if_longer_than {
-            if elapsed > warn_limit {
-                crate::warn!(
-                    self.logger =>
-                    "Timer '{}' took {:?}. Which was longer than the expected limit of {:?}",
-                    self.name,
-                    elapsed,
-                    warn_limit
-                );
-                self.done = true;
-                return;
-            }
+        if let Some(warn_limit) = self.warn_if_longer_than
+            && elapsed > warn_limit
+        {
+            crate::warn!(
+                self.logger =>
+                "Timer '{}' took {:?}. Which was longer than the expected limit of {:?}",
+                self.name,
+                elapsed,
+                warn_limit
+            );
+            self.done = true;
+            return;
         }
         crate::trace!(
             self.logger =>

extensions/glsl/src/glsl.rs πŸ”—

@@ -16,10 +16,10 @@ impl GlslExtension {
             return Ok(path);
         }
 
-        if let Some(path) = &self.cached_binary_path {
-            if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
-                return Ok(path.clone());
-            }
+        if let Some(path) = &self.cached_binary_path
+            && fs::metadata(path).map_or(false, |stat| stat.is_file())
+        {
+            return Ok(path.clone());
         }
 
         zed::set_language_server_installation_status(

extensions/ruff/src/ruff.rs πŸ”—

@@ -38,13 +38,13 @@ impl RuffExtension {
             });
         }
 
-        if let Some(path) = &self.cached_binary_path {
-            if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
-                return Ok(RuffBinary {
-                    path: path.clone(),
-                    args: binary_args,
-                });
-            }
+        if let Some(path) = &self.cached_binary_path
+            && fs::metadata(path).map_or(false, |stat| stat.is_file())
+        {
+            return Ok(RuffBinary {
+                path: path.clone(),
+                args: binary_args,
+            });
         }
 
         zed::set_language_server_installation_status(

extensions/snippets/src/snippets.rs πŸ”—

@@ -17,10 +17,10 @@ impl SnippetExtension {
             return Ok(path);
         }
 
-        if let Some(path) = &self.cached_binary_path {
-            if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
-                return Ok(path.clone());
-            }
+        if let Some(path) = &self.cached_binary_path
+            && fs::metadata(path).map_or(false, |stat| stat.is_file())
+        {
+            return Ok(path.clone());
         }
 
         zed::set_language_server_installation_status(

extensions/test-extension/src/test_extension.rs πŸ”—

@@ -18,10 +18,10 @@ impl TestExtension {
 
         println!("{}", String::from_utf8_lossy(&echo_output.stdout));
 
-        if let Some(path) = &self.cached_binary_path {
-            if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
-                return Ok(path.clone());
-            }
+        if let Some(path) = &self.cached_binary_path
+            && fs::metadata(path).map_or(false, |stat| stat.is_file())
+        {
+            return Ok(path.clone());
         }
 
         zed::set_language_server_installation_status(

extensions/toml/src/toml.rs πŸ”—

@@ -39,13 +39,13 @@ impl TomlExtension {
             });
         }
 
-        if let Some(path) = &self.cached_binary_path {
-            if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
-                return Ok(TaploBinary {
-                    path: path.clone(),
-                    args: binary_args,
-                });
-            }
+        if let Some(path) = &self.cached_binary_path
+            && fs::metadata(path).map_or(false, |stat| stat.is_file())
+        {
+            return Ok(TaploBinary {
+                path: path.clone(),
+                args: binary_args,
+            });
         }
 
         zed::set_language_server_installation_status(