extension: Make worktree
argument to run_slash_command
optional (#15658)
This PR updates the extension API to make the `worktree` argument to `run_slash_command` optional. We may not always have a worktree, and not all slash commands need them, so by making it optional we can allow individual slash commands to decide what to do when there is no worktree. Release Notes: - N/A
This commit is contained in:
parent
88f29c8355
commit
771424e4f9
5 changed files with 12 additions and 9 deletions
|
@ -181,7 +181,7 @@ impl zed::Extension for GleamExtension {
|
|||
&self,
|
||||
command: SlashCommand,
|
||||
argument: Option<String>,
|
||||
worktree: &zed::Worktree,
|
||||
worktree: Option<&zed::Worktree>,
|
||||
) -> Result<SlashCommandOutput, String> {
|
||||
match command.name.as_str() {
|
||||
"gleam-docs" => {
|
||||
|
@ -218,6 +218,8 @@ impl zed::Extension for GleamExtension {
|
|||
})
|
||||
}
|
||||
"gleam-project" => {
|
||||
let worktree = worktree.ok_or_else(|| "no worktree")?;
|
||||
|
||||
let mut text = String::new();
|
||||
text.push_str("You are in a Gleam project.\n");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue