Fix slash command argument completion bugs (#16233)
Release Notes: - N/A --------- Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
6365000b68
commit
8df21f7bcd
8 changed files with 67 additions and 27 deletions
|
@ -150,6 +150,7 @@ impl SlashCommand for DiagnosticsSlashCommand {
|
|||
label: completion.clone().into(),
|
||||
new_text: completion,
|
||||
run_command: true,
|
||||
replace_previous_arguments: false,
|
||||
})
|
||||
.collect())
|
||||
})
|
||||
|
|
|
@ -182,6 +182,7 @@ impl SlashCommand for DocsSlashCommand {
|
|||
label: item.clone().into(),
|
||||
new_text: item.to_string(),
|
||||
run_command: true,
|
||||
replace_previous_arguments: false,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
@ -194,6 +195,7 @@ impl SlashCommand for DocsSlashCommand {
|
|||
label: "No available docs providers.".into(),
|
||||
new_text: String::new(),
|
||||
run_command: false,
|
||||
replace_previous_arguments: false,
|
||||
}]);
|
||||
}
|
||||
|
||||
|
@ -203,6 +205,7 @@ impl SlashCommand for DocsSlashCommand {
|
|||
label: provider.to_string().into(),
|
||||
new_text: provider.to_string(),
|
||||
run_command: false,
|
||||
replace_previous_arguments: false,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
@ -234,6 +237,7 @@ impl SlashCommand for DocsSlashCommand {
|
|||
label: format!("{package_name} (unindexed)").into(),
|
||||
new_text: format!("{package_name}"),
|
||||
run_command: true,
|
||||
replace_previous_arguments: false,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
items.extend(workspace_crate_completions);
|
||||
|
@ -247,6 +251,7 @@ impl SlashCommand for DocsSlashCommand {
|
|||
.into(),
|
||||
new_text: provider.to_string(),
|
||||
run_command: false,
|
||||
replace_previous_arguments: false,
|
||||
}]);
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,8 @@ impl SlashCommand for FileSlashCommand {
|
|||
Some(ArgumentCompletion {
|
||||
label,
|
||||
new_text: text,
|
||||
run_command: false,
|
||||
run_command: true,
|
||||
replace_previous_arguments: false,
|
||||
})
|
||||
})
|
||||
.collect())
|
||||
|
|
|
@ -35,7 +35,7 @@ impl SlashCommand for PromptSlashCommand {
|
|||
cx: &mut WindowContext,
|
||||
) -> Task<Result<Vec<ArgumentCompletion>>> {
|
||||
let store = PromptStore::global(cx);
|
||||
let query = arguments.last().cloned().unwrap_or_default();
|
||||
let query = arguments.to_owned().join(" ");
|
||||
cx.background_executor().spawn(async move {
|
||||
let prompts = store.await?.search(query).await;
|
||||
Ok(prompts
|
||||
|
@ -46,6 +46,7 @@ impl SlashCommand for PromptSlashCommand {
|
|||
label: prompt_title.clone().into(),
|
||||
new_text: prompt_title,
|
||||
run_command: true,
|
||||
replace_previous_arguments: true,
|
||||
})
|
||||
})
|
||||
.collect())
|
||||
|
@ -59,12 +60,13 @@ impl SlashCommand for PromptSlashCommand {
|
|||
_delegate: Option<Arc<dyn LspAdapterDelegate>>,
|
||||
cx: &mut WindowContext,
|
||||
) -> Task<Result<SlashCommandOutput>> {
|
||||
let Some(title) = arguments.first() else {
|
||||
let title = arguments.to_owned().join(" ");
|
||||
if title.trim().is_empty() {
|
||||
return Task::ready(Err(anyhow!("missing prompt name")));
|
||||
};
|
||||
|
||||
let store = PromptStore::global(cx);
|
||||
let title = SharedString::from(title.to_string());
|
||||
let title = SharedString::from(title.clone());
|
||||
let prompt = cx.background_executor().spawn({
|
||||
let title = title.clone();
|
||||
async move {
|
||||
|
|
|
@ -76,6 +76,7 @@ impl SlashCommand for TabSlashCommand {
|
|||
Some(ArgumentCompletion {
|
||||
label: path_string.clone().into(),
|
||||
new_text: path_string,
|
||||
replace_previous_arguments: false,
|
||||
run_command,
|
||||
})
|
||||
});
|
||||
|
@ -83,6 +84,7 @@ impl SlashCommand for TabSlashCommand {
|
|||
Ok(Some(ArgumentCompletion {
|
||||
label: ALL_TABS_COMPLETION_ITEM.into(),
|
||||
new_text: ALL_TABS_COMPLETION_ITEM.to_owned(),
|
||||
replace_previous_arguments: false,
|
||||
run_command: true,
|
||||
})
|
||||
.into_iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue