Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

assistant: Clean up completion building in `/docs` command (#13877)

Marshall Bowers950e7e541400
diff --git a/crates/assistant/src/slash_command/docs_command.rs b/crates/assistant/src/slash_command/docs_command.rs
index 9b27635fd23..c7e90edfd70 100644
--- a/crates/assistant/src/slash_command/docs_command.rs
+++ b/crates/assistant/src/slash_command/docs_command.rs
@@ -104,12 +104,7 @@ impl SlashCommand for DocsSlashCommand {
.ok_or_else(|| anyhow!("no docs provider specified"))
.and_then(|provider| IndexedDocsStore::try_global(provider, cx));
cx.background_executor().spawn(async move {
- /// HACK: Prefixes the completions with the provider ID so that it doesn't get deleted
- /// 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(
+ fn build_completions(
provider: ProviderId,
items: Vec<String>,
) -> Vec<ArgumentCompletion> {
@@ -149,7 +144,7 @@ impl SlashCommand for DocsSlashCommand {
}
let items = store.search(package).await;
- Ok(prefix_with_provider(provider, items))
+ Ok(build_completions(provider, items))
}
DocsSlashCommandArgs::SearchItemDocs {
provider,
@@ -158,7 +153,7 @@ impl SlashCommand for DocsSlashCommand {
} => {
let store = store?;
let items = store.search(item_path).await;
- Ok(prefix_with_provider(provider, items))
+ Ok(build_completions(provider, items))
}
}
})