mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 19:05:08 +03:00
assistant: Indicate when the /rustdoc
output is from the index (#13148)
This PR makes it so that when `/rustdoc` returns content from the local index it indicates as such in the placeholder. Release Notes: - N/A
This commit is contained in:
parent
0c28b6a11a
commit
e8862c45cc
@ -10,20 +10,11 @@ use gpui::{AppContext, Model, Task, WeakView};
|
|||||||
use http::{AsyncBody, HttpClient, HttpClientWithUrl};
|
use http::{AsyncBody, HttpClient, HttpClientWithUrl};
|
||||||
use language::LspAdapterDelegate;
|
use language::LspAdapterDelegate;
|
||||||
use project::{Project, ProjectPath};
|
use project::{Project, ProjectPath};
|
||||||
use rustdoc::{convert_rustdoc_to_markdown, RustdocStore};
|
use rustdoc::{convert_rustdoc_to_markdown, CrateName, LocalProvider, RustdocSource, RustdocStore};
|
||||||
use rustdoc::{CrateName, LocalProvider};
|
|
||||||
use ui::{prelude::*, ButtonLike, ElevationIndex};
|
use ui::{prelude::*, ButtonLike, ElevationIndex};
|
||||||
use util::{maybe, ResultExt};
|
use util::{maybe, ResultExt};
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
enum RustdocSource {
|
|
||||||
/// The docs were sourced from local `cargo doc` output.
|
|
||||||
Local,
|
|
||||||
/// The docs were sourced from `docs.rs`.
|
|
||||||
DocsDotRs,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct RustdocSlashCommand;
|
pub(crate) struct RustdocSlashCommand;
|
||||||
|
|
||||||
impl RustdocSlashCommand {
|
impl RustdocSlashCommand {
|
||||||
@ -193,7 +184,7 @@ impl SlashCommand for RustdocSlashCommand {
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
if let Ok(item_docs) = item_docs {
|
if let Ok(item_docs) = item_docs {
|
||||||
anyhow::Ok((RustdocSource::Local, item_docs.docs().to_owned()))
|
anyhow::Ok((RustdocSource::Index, item_docs.docs().to_owned()))
|
||||||
} else {
|
} else {
|
||||||
Self::build_message(
|
Self::build_message(
|
||||||
fs,
|
fs,
|
||||||
@ -261,6 +252,7 @@ impl RenderOnce for RustdocPlaceholder {
|
|||||||
.child(Label::new(format!(
|
.child(Label::new(format!(
|
||||||
"rustdoc ({source}): {crate_path}",
|
"rustdoc ({source}): {crate_path}",
|
||||||
source = match self.source {
|
source = match self.source {
|
||||||
|
RustdocSource::Index => "index",
|
||||||
RustdocSource::Local => "local",
|
RustdocSource::Local => "local",
|
||||||
RustdocSource::DocsDotRs => "docs.rs",
|
RustdocSource::DocsDotRs => "docs.rs",
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ use crate::{
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum RustdocSource {
|
pub enum RustdocSource {
|
||||||
|
/// The docs were sourced from Zed's rustdoc index.
|
||||||
|
Index,
|
||||||
/// The docs were sourced from local `cargo doc` output.
|
/// The docs were sourced from local `cargo doc` output.
|
||||||
Local,
|
Local,
|
||||||
/// The docs were sourced from `docs.rs`.
|
/// The docs were sourced from `docs.rs`.
|
||||||
|
Loading…
Reference in New Issue
Block a user