Persist index for /rustdoc in LMDB (#12988)

This PR updates the `/rustdoc` command with persistence for the
documented rustdoc items.

Now when you run `/rustdoc --index <CRATE_NAME>` it will index the crate
and store the results in LMDB.

The documented items will then be read from the database when searching
using `/rustdoc` and persist across restarts of Zed.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-06-13 12:07:26 -04:00 committed by GitHub
parent 6c70a809ec
commit 85acc2be44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 174 additions and 38 deletions

View file

@ -124,10 +124,7 @@ impl SlashCommand for RustdocSlashCommand {
let store = RustdocStore::global(cx);
cx.background_executor().spawn(async move {
let items = store.search(query).await;
Ok(items
.into_iter()
.map(|(crate_name, item)| format!("{crate_name}::{}", item.display()))
.collect())
Ok(items)
})
}
@ -228,7 +225,7 @@ impl SlashCommand for RustdocSlashCommand {
.await;
if let Ok(item_docs) = item_docs {
anyhow::Ok((RustdocSource::Local, item_docs))
anyhow::Ok((RustdocSource::Local, item_docs.docs().to_owned()))
} else {
Self::build_message(
fs,