diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index c54a818206ff66d725b7bb3dec99b8e18abc4d0c..445d6a6df6b7395997d9e0bab6ccff153dfe99c5 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 5511223ab93905e94bcd4dbc238f8cc2842d794a..f52225c78c50cc670552eaf168248da70b5eb701 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 0f46937560f930ec631b86bec3e20b3492b6d5f0..ad11e0ee081da5085f48164c831ec9be9048b44b 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 ccc9d1fbdb095358661bffd07a5394150c6b4f71..d01eea2f0dd90122d16313f025f7a242d485095f 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 1e9d0503a0cc783d16ea3abe5afb23e44ded2d58..d8413e286ed0753a700f76556479f9f15a9a7caa 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 567d280eb78a9cae2d41090ce6d8c56f1bbc3edd..864ef3c1ef5904b6c5b99b532c7a8be20c03deb8 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 8934d68c1638439ae5821f10de48caf61d888a7e..e1a784f71aee4379fd57c9dfa210b2df156e0639 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 af35bacd2a5c99813fa2e215de1cda8894e04c41..b10a34e44e65f132d41d631b0616f1d644141002 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 73f4f7b2565f8303d62ac96d58fbf0a7441e4036..ccd3d713d8e9bc965cca25b0132012bd4aededca 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 c6c394f56bde2bc5d323af13f3a394b6c9beb423..581b216b572aff6146983e43d9225fdd0ba97c5a 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 1edf2d51df084fdd4cb513df88bc350e3546446e..24b4802230bf61fd14cd86b75e9f6bbd4224bb7c 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 cdf1da7a9b7c9b12d894fef19e55b963fb445a68..979b1edb89f2f948ab3e80ce6b7db97ff8f565e5 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 11a056f0daf5cbcd6429c5d327bb8b50e141096c..4788063aa1b6db8316a36b1ae464eeea1d2b1f8b 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 78be293bd7c7d195df11dd2a04ea395d2c6af147..41da270d5abe9a9ba3ee480d3284bde68c4617dd 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 90c3cb0fb955dfa72b5df851de78873815b98354..277e13238f63612e9da0c9df61e3ecd3b18b47b8 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 5f917363a23073c0faf2109e4ae4f9bdda8b5138..b33c2ce50b41cd1e9f9c9be287d05f3b112d7762 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 086ddafbb019cf3b2a95cf382a6b7ff21640b751..a7bc1523b93a09e43390e90f33119c6afa1ac4ae 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(