Further improve /tabs command and slash arguments completion (#16216)
* renames `/tabs` to `/tab` * allows to insert multiple tabs when fuzzy matching by the names * improve slash command completion API, introduce a notion of multiple arguments * properly fire off commands on arguments' completions with `run_command: true` Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <marshall@zed.dev>
This commit is contained in:
parent
88a12b60a9
commit
8fe2de1737
23 changed files with 332 additions and 263 deletions
|
@ -29,12 +29,13 @@ impl SlashCommand for PromptSlashCommand {
|
|||
|
||||
fn complete_argument(
|
||||
self: Arc<Self>,
|
||||
query: String,
|
||||
arguments: &[String],
|
||||
_cancellation_flag: Arc<AtomicBool>,
|
||||
_workspace: Option<WeakView<Workspace>>,
|
||||
cx: &mut WindowContext,
|
||||
) -> Task<Result<Vec<ArgumentCompletion>>> {
|
||||
let store = PromptStore::global(cx);
|
||||
let query = arguments.last().cloned().unwrap_or_default();
|
||||
cx.background_executor().spawn(async move {
|
||||
let prompts = store.await?.search(query).await;
|
||||
Ok(prompts
|
||||
|
@ -53,12 +54,12 @@ impl SlashCommand for PromptSlashCommand {
|
|||
|
||||
fn run(
|
||||
self: Arc<Self>,
|
||||
title: Option<&str>,
|
||||
arguments: &[String],
|
||||
_workspace: WeakView<Workspace>,
|
||||
_delegate: Option<Arc<dyn LspAdapterDelegate>>,
|
||||
cx: &mut WindowContext,
|
||||
) -> Task<Result<SlashCommandOutput>> {
|
||||
let Some(title) = title else {
|
||||
let Some(title) = arguments.first() else {
|
||||
return Task::ready(Err(anyhow!("missing prompt name")));
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue