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
|
@ -91,10 +91,11 @@ 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 resource = if let Some(delegate) = delegate {
|
||||
Some(store.data_mut().table().push(delegate)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let output = extension
|
||||
.call_run_slash_command(
|
||||
store,
|
||||
|
|
|
@ -277,7 +277,7 @@ impl Extension {
|
|||
store: &mut Store<WasmState>,
|
||||
command: &SlashCommand,
|
||||
argument: Option<&str>,
|
||||
resource: Resource<Arc<dyn LspAdapterDelegate>>,
|
||||
resource: Option<Resource<Arc<dyn LspAdapterDelegate>>>,
|
||||
) -> Result<Result<SlashCommandOutput, String>> {
|
||||
match self {
|
||||
Extension::V007(ext) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue