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:
parent
ca18549e02
commit
ad4e52842c
8 changed files with 73 additions and 38 deletions
9
crates/extension_api/wit/since_v0.0.7/common.wit
Normal file
9
crates/extension_api/wit/since_v0.0.7/common.wit
Normal file
|
@ -0,0 +1,9 @@
|
|||
interface common {
|
||||
/// A (half-open) range (`[start, end)`).
|
||||
record range {
|
||||
/// The start of the range (inclusive).
|
||||
start: u32,
|
||||
/// The end of the range (exclusive).
|
||||
end: u32,
|
||||
}
|
||||
}
|
|
@ -5,8 +5,9 @@ world extension {
|
|||
import platform;
|
||||
import nodejs;
|
||||
|
||||
use common.{range};
|
||||
use lsp.{completion, symbol};
|
||||
use slash-command.{slash-command};
|
||||
use slash-command.{slash-command, slash-command-output};
|
||||
|
||||
/// Initializes the extension.
|
||||
export init-extension: func();
|
||||
|
@ -118,17 +119,9 @@ world extension {
|
|||
highlight-name: option<string>,
|
||||
}
|
||||
|
||||
/// A (half-open) range (`[start, end)`).
|
||||
record range {
|
||||
/// The start of the range (inclusive).
|
||||
start: u32,
|
||||
/// The end of the range (exclusive).
|
||||
end: u32,
|
||||
}
|
||||
|
||||
export labels-for-completions: func(language-server-id: string, completions: list<completion>) -> result<list<option<code-label>>, string>;
|
||||
export labels-for-symbols: func(language-server-id: string, symbols: list<symbol>) -> result<list<option<code-label>>, string>;
|
||||
|
||||
/// Runs the provided slash command.
|
||||
export run-slash-command: func(command: slash-command, argument: option<string>, worktree: borrow<worktree>) -> result<option<string>, string>;
|
||||
export run-slash-command: func(command: slash-command, argument: option<string>, worktree: borrow<worktree>) -> result<slash-command-output, string>;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
interface slash-command {
|
||||
use common.{range};
|
||||
|
||||
/// A slash command for use in the Assistant.
|
||||
record slash-command {
|
||||
/// The name of the slash command.
|
||||
|
@ -10,4 +12,20 @@ interface slash-command {
|
|||
/// Whether this slash command requires an argument.
|
||||
requires-argument: bool,
|
||||
}
|
||||
|
||||
/// The output of a slash command.
|
||||
record slash-command-output {
|
||||
/// The text produced by the slash command.
|
||||
text: string,
|
||||
/// The list of sections to show in the slash command placeholder.
|
||||
sections: list<slash-command-output-section>,
|
||||
}
|
||||
|
||||
/// A section in the slash command output.
|
||||
record slash-command-output-section {
|
||||
/// The range this section occupies.
|
||||
range: range,
|
||||
/// The label to display in the placeholder for this section.
|
||||
label: string,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue