mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-08 03:38:12 +00:00
assistant: Clean up completion building in /docs
command (#13877)
This PR cleans up the building of completions in the `/docs` command a bit after #13876. Release Notes: - N/A
This commit is contained in:
parent
68accaeb00
commit
950e7e5414
1 changed files with 3 additions and 8 deletions
|
@ -104,12 +104,7 @@ impl SlashCommand for DocsSlashCommand {
|
||||||
.ok_or_else(|| anyhow!("no docs provider specified"))
|
.ok_or_else(|| anyhow!("no docs provider specified"))
|
||||||
.and_then(|provider| IndexedDocsStore::try_global(provider, cx));
|
.and_then(|provider| IndexedDocsStore::try_global(provider, cx));
|
||||||
cx.background_executor().spawn(async move {
|
cx.background_executor().spawn(async move {
|
||||||
/// HACK: Prefixes the completions with the provider ID so that it doesn't get deleted
|
fn build_completions(
|
||||||
/// when a completion is accepted.
|
|
||||||
///
|
|
||||||
/// We will likely want to extend `complete_argument` with support for replacing just
|
|
||||||
/// a particular range of the argument when a completion is accepted.
|
|
||||||
fn prefix_with_provider(
|
|
||||||
provider: ProviderId,
|
provider: ProviderId,
|
||||||
items: Vec<String>,
|
items: Vec<String>,
|
||||||
) -> Vec<ArgumentCompletion> {
|
) -> Vec<ArgumentCompletion> {
|
||||||
|
@ -149,7 +144,7 @@ impl SlashCommand for DocsSlashCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
let items = store.search(package).await;
|
let items = store.search(package).await;
|
||||||
Ok(prefix_with_provider(provider, items))
|
Ok(build_completions(provider, items))
|
||||||
}
|
}
|
||||||
DocsSlashCommandArgs::SearchItemDocs {
|
DocsSlashCommandArgs::SearchItemDocs {
|
||||||
provider,
|
provider,
|
||||||
|
@ -158,7 +153,7 @@ impl SlashCommand for DocsSlashCommand {
|
||||||
} => {
|
} => {
|
||||||
let store = store?;
|
let store = store?;
|
||||||
let items = store.search(item_path).await;
|
let items = store.search(item_path).await;
|
||||||
Ok(prefix_with_provider(provider, items))
|
Ok(build_completions(provider, items))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue