Make slash commands defined in extensions return SlashCommandOutput (#13237)

This PR extends the interface for slash commands defined in extensions
to have them return `SlashCommandOutput`.

This allows for slash commands to return multiple output sections for a
single piece of generated text.

Note that we don't allow specifying the icon to display in the
placeholder, as we don't want to commit to that in our API at the
moment.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-06-18 17:28:01 -04:00 committed by GitHub
parent ca18549e02
commit ad4e52842c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 73 additions and 38 deletions

View file

@ -24,7 +24,7 @@ pub use wit::{
npm_package_latest_version,
},
zed::extension::platform::{current_platform, Architecture, Os},
zed::extension::slash_command::SlashCommand,
zed::extension::slash_command::{SlashCommand, SlashCommandOutput, SlashCommandOutputSection},
CodeLabel, CodeLabelSpan, CodeLabelSpanLiteral, Command, DownloadedFileType, EnvVars,
LanguageServerInstallationStatus, Range, Worktree,
};
@ -114,8 +114,8 @@ pub trait Extension: Send + Sync {
_command: SlashCommand,
_argument: Option<String>,
_worktree: &Worktree,
) -> Result<Option<String>, String> {
Ok(None)
) -> Result<SlashCommandOutput, String> {
Err("`run_slash_command` not implemented".to_string())
}
}
@ -229,7 +229,7 @@ impl wit::Guest for Component {
command: SlashCommand,
argument: Option<String>,
worktree: &Worktree,
) -> Result<Option<String>, String> {
) -> Result<SlashCommandOutput, String> {
extension().run_slash_command(command, argument, worktree)
}
}