diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index c54a818206..445d6a6df6 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -1596,18 +1596,16 @@ impl ContextEditor { cx: &mut ViewContext, ) { if let Some(command) = SlashCommandRegistry::global(cx).command(name) { - if let Some(lsp_adapter_delegate) = self.lsp_adapter_delegate.clone() { - let argument = argument.map(ToString::to_string); - let output = command.run(argument.as_deref(), workspace, lsp_adapter_delegate, cx); - self.context.update(cx, |context, cx| { - context.insert_command_output( - command_range, - output, - insert_trailing_newline, - cx, - ) - }); - } + let argument = argument.map(ToString::to_string); + let output = command.run( + argument.as_deref(), + workspace, + self.lsp_adapter_delegate.clone(), + cx, + ); + self.context.update(cx, |context, cx| { + context.insert_command_output(command_range, output, insert_trailing_newline, cx) + }); } } diff --git a/crates/assistant/src/context.rs b/crates/assistant/src/context.rs index 5511223ab9..f52225c78c 100644 --- a/crates/assistant/src/context.rs +++ b/crates/assistant/src/context.rs @@ -3414,7 +3414,7 @@ mod tests { self: Arc, _argument: Option<&str>, _workspace: WeakView, - _delegate: Arc, + _delegate: Option>, _cx: &mut WindowContext, ) -> Task> { Task::ready(Ok(SlashCommandOutput { diff --git a/crates/assistant/src/slash_command/active_command.rs b/crates/assistant/src/slash_command/active_command.rs index 0f46937560..ad11e0ee08 100644 --- a/crates/assistant/src/slash_command/active_command.rs +++ b/crates/assistant/src/slash_command/active_command.rs @@ -46,7 +46,7 @@ impl SlashCommand for ActiveSlashCommand { self: Arc, _argument: Option<&str>, workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let output = workspace.update(cx, |workspace, cx| { diff --git a/crates/assistant/src/slash_command/default_command.rs b/crates/assistant/src/slash_command/default_command.rs index ccc9d1fbdb..d01eea2f0d 100644 --- a/crates/assistant/src/slash_command/default_command.rs +++ b/crates/assistant/src/slash_command/default_command.rs @@ -44,7 +44,7 @@ impl SlashCommand for DefaultSlashCommand { self: Arc, _argument: Option<&str>, _workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let store = PromptStore::global(cx); diff --git a/crates/assistant/src/slash_command/diagnostics_command.rs b/crates/assistant/src/slash_command/diagnostics_command.rs index 1e9d0503a0..d8413e286e 100644 --- a/crates/assistant/src/slash_command/diagnostics_command.rs +++ b/crates/assistant/src/slash_command/diagnostics_command.rs @@ -158,7 +158,7 @@ impl SlashCommand for DiagnosticsSlashCommand { self: Arc, argument: Option<&str>, workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let Some(workspace) = workspace.upgrade() else { diff --git a/crates/assistant/src/slash_command/docs_command.rs b/crates/assistant/src/slash_command/docs_command.rs index 567d280eb7..864ef3c1ef 100644 --- a/crates/assistant/src/slash_command/docs_command.rs +++ b/crates/assistant/src/slash_command/docs_command.rs @@ -242,7 +242,7 @@ impl SlashCommand for DocsSlashCommand { self: Arc, argument: Option<&str>, _workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let Some(argument) = argument else { diff --git a/crates/assistant/src/slash_command/fetch_command.rs b/crates/assistant/src/slash_command/fetch_command.rs index 8934d68c16..e1a784f71a 100644 --- a/crates/assistant/src/slash_command/fetch_command.rs +++ b/crates/assistant/src/slash_command/fetch_command.rs @@ -129,7 +129,7 @@ impl SlashCommand for FetchSlashCommand { self: Arc, argument: Option<&str>, workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let Some(argument) = argument else { diff --git a/crates/assistant/src/slash_command/file_command.rs b/crates/assistant/src/slash_command/file_command.rs index af35bacd2a..b10a34e44e 100644 --- a/crates/assistant/src/slash_command/file_command.rs +++ b/crates/assistant/src/slash_command/file_command.rs @@ -136,7 +136,7 @@ impl SlashCommand for FileSlashCommand { self: Arc, argument: Option<&str>, workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let Some(workspace) = workspace.upgrade() else { diff --git a/crates/assistant/src/slash_command/now_command.rs b/crates/assistant/src/slash_command/now_command.rs index 73f4f7b256..ccd3d713d8 100644 --- a/crates/assistant/src/slash_command/now_command.rs +++ b/crates/assistant/src/slash_command/now_command.rs @@ -44,7 +44,7 @@ impl SlashCommand for NowSlashCommand { self: Arc, _argument: Option<&str>, _workspace: WeakView, - _delegate: Arc, + _delegate: Option>, _cx: &mut WindowContext, ) -> Task> { let now = Local::now(); diff --git a/crates/assistant/src/slash_command/project_command.rs b/crates/assistant/src/slash_command/project_command.rs index c6c394f56b..581b216b57 100644 --- a/crates/assistant/src/slash_command/project_command.rs +++ b/crates/assistant/src/slash_command/project_command.rs @@ -119,7 +119,7 @@ impl SlashCommand for ProjectSlashCommand { self: Arc, _argument: Option<&str>, workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let output = workspace.update(cx, |workspace, cx| { diff --git a/crates/assistant/src/slash_command/prompt_command.rs b/crates/assistant/src/slash_command/prompt_command.rs index 1edf2d51df..24b4802230 100644 --- a/crates/assistant/src/slash_command/prompt_command.rs +++ b/crates/assistant/src/slash_command/prompt_command.rs @@ -55,7 +55,7 @@ impl SlashCommand for PromptSlashCommand { self: Arc, title: Option<&str>, _workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let Some(title) = title else { diff --git a/crates/assistant/src/slash_command/search_command.rs b/crates/assistant/src/slash_command/search_command.rs index cdf1da7a9b..979b1edb89 100644 --- a/crates/assistant/src/slash_command/search_command.rs +++ b/crates/assistant/src/slash_command/search_command.rs @@ -54,7 +54,7 @@ impl SlashCommand for SearchSlashCommand { self: Arc, argument: Option<&str>, workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let Some(workspace) = workspace.upgrade() else { diff --git a/crates/assistant/src/slash_command/symbols_command.rs b/crates/assistant/src/slash_command/symbols_command.rs index 11a056f0da..4788063aa1 100644 --- a/crates/assistant/src/slash_command/symbols_command.rs +++ b/crates/assistant/src/slash_command/symbols_command.rs @@ -42,7 +42,7 @@ impl SlashCommand for OutlineSlashCommand { self: Arc, _argument: Option<&str>, workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let output = workspace.update(cx, |workspace, cx| { diff --git a/crates/assistant/src/slash_command/tabs_command.rs b/crates/assistant/src/slash_command/tabs_command.rs index 78be293bd7..41da270d5a 100644 --- a/crates/assistant/src/slash_command/tabs_command.rs +++ b/crates/assistant/src/slash_command/tabs_command.rs @@ -46,7 +46,7 @@ impl SlashCommand for TabsSlashCommand { self: Arc, _argument: Option<&str>, workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let open_buffers = workspace.update(cx, |workspace, cx| { diff --git a/crates/assistant/src/slash_command/term_command.rs b/crates/assistant/src/slash_command/term_command.rs index 90c3cb0fb9..277e13238f 100644 --- a/crates/assistant/src/slash_command/term_command.rs +++ b/crates/assistant/src/slash_command/term_command.rs @@ -58,7 +58,7 @@ impl SlashCommand for TermSlashCommand { self: Arc, argument: Option<&str>, workspace: WeakView, - _delegate: Arc, + _delegate: Option>, cx: &mut WindowContext, ) -> Task> { let Some(workspace) = workspace.upgrade() else { diff --git a/crates/assistant_slash_command/src/assistant_slash_command.rs b/crates/assistant_slash_command/src/assistant_slash_command.rs index 5f917363a2..b33c2ce50b 100644 --- a/crates/assistant_slash_command/src/assistant_slash_command.rs +++ b/crates/assistant_slash_command/src/assistant_slash_command.rs @@ -49,7 +49,7 @@ pub trait SlashCommand: 'static + Send + Sync { // // It may be that `LspAdapterDelegate` needs a more general name, or // perhaps another kind of delegate is needed here. - delegate: Arc, + delegate: Option>, cx: &mut WindowContext, ) -> Task>; } diff --git a/crates/extension/src/extension_slash_command.rs b/crates/extension/src/extension_slash_command.rs index 086ddafbb0..a7bc1523b9 100644 --- a/crates/extension/src/extension_slash_command.rs +++ b/crates/extension/src/extension_slash_command.rs @@ -81,7 +81,7 @@ impl SlashCommand for ExtensionSlashCommand { self: Arc, argument: Option<&str>, _workspace: WeakView, - delegate: Arc, + delegate: Option>, cx: &mut WindowContext, ) -> Task> { let argument = argument.map(|arg| arg.to_string()); @@ -91,6 +91,9 @@ impl SlashCommand for ExtensionSlashCommand { let this = self.clone(); move |extension, store| { async move { + let delegate = delegate.ok_or_else(|| { + anyhow!("no worktree for extension slash command") + })?; let resource = store.data_mut().table().push(delegate)?; let output = extension .call_run_slash_command(