Asynchronously request completion documentation if not present

This commit is contained in:
Julia 2023-09-28 14:16:30 -04:00
parent fcaf48eb49
commit fe62423344
2 changed files with 61 additions and 67 deletions

View file

@ -3,57 +3,17 @@ use std::sync::Arc;
use crate::{Language, LanguageRegistry};
use futures::FutureExt;
use gpui::{
elements::Text,
fonts::{HighlightStyle, Underline, Weight},
platform::{CursorStyle, MouseButton},
CursorRegion, MouseRegion, ViewContext,
};
use gpui::fonts::{HighlightStyle, Underline, Weight};
use pulldown_cmark::{CodeBlockKind, Event, Options, Parser, Tag};
#[derive(Debug, Clone)]
pub struct RenderedMarkdown {
text: String,
highlights: Vec<(Range<usize>, HighlightStyle)>,
region_ranges: Vec<Range<usize>>,
regions: Vec<RenderedRegion>,
pub text: String,
pub highlights: Vec<(Range<usize>, HighlightStyle)>,
pub region_ranges: Vec<Range<usize>>,
pub regions: Vec<RenderedRegion>,
}
// impl RenderedMarkdown {
// pub fn render(&self, style: &theme::Editor, cx: &mut ViewContext<Editor>) -> Text {
// let code_span_background_color = style.document_highlight_read_background;
// let view_id = cx.view_id();
// let mut region_id = 0;
// Text::new(text, style.text.clone())
// .with_highlights(highlights)
// .with_custom_runs(region_ranges, move |ix, bounds, scene, _| {
// region_id += 1;
// let region = regions[ix].clone();
// if let Some(url) = region.link_url {
// scene.push_cursor_region(CursorRegion {
// bounds,
// style: CursorStyle::PointingHand,
// });
// scene.push_mouse_region(
// MouseRegion::new::<Editor>(view_id, region_id, bounds)
// .on_click::<Editor, _>(MouseButton::Left, move |_, _, cx| {
// cx.platform().open_url(&url)
// }),
// );
// }
// if region.code {
// scene.push_quad(gpui::Quad {
// bounds,
// background: Some(code_span_background_color),
// border: Default::default(),
// corner_radii: (2.0).into(),
// });
// }
// })
// .with_soft_wrap(true)
// }
// }
#[derive(Debug, Clone)]
pub struct RenderedRegion {
pub code: bool,