Add caching of parsed completion documentation markdown to reduce flicker when selecting (#31546)
Related to #31460 and #28635. Release Notes: - Fixed redraw delay of documentation from language server completions and added caching to reduce flicker when using arrow keys to change selection.
This commit is contained in:
parent
31d908fc74
commit
506beafe10
8 changed files with 300 additions and 95 deletions
|
@ -20,6 +20,7 @@ test-support = [
|
|||
|
||||
[dependencies]
|
||||
base64.workspace = true
|
||||
futures.workspace = true
|
||||
gpui.workspace = true
|
||||
language.workspace = true
|
||||
linkify.workspace = true
|
||||
|
|
|
@ -67,14 +67,8 @@ struct MarkdownExample {
|
|||
|
||||
impl MarkdownExample {
|
||||
pub fn new(text: SharedString, language_registry: Arc<LanguageRegistry>, cx: &mut App) -> Self {
|
||||
let markdown = cx.new(|cx| {
|
||||
Markdown::new(
|
||||
text,
|
||||
Some(language_registry),
|
||||
Some("TypeScript".to_string()),
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let markdown = cx
|
||||
.new(|cx| Markdown::new(text, Some(language_registry), Some("TypeScript".into()), cx));
|
||||
Self { markdown }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ pub mod parser;
|
|||
mod path_range;
|
||||
|
||||
use base64::Engine as _;
|
||||
use futures::FutureExt as _;
|
||||
use language::LanguageName;
|
||||
use log::Level;
|
||||
pub use path_range::{LineCol, PathWithRange};
|
||||
|
||||
|
@ -101,7 +103,7 @@ pub struct Markdown {
|
|||
pending_parse: Option<Task<()>>,
|
||||
focus_handle: FocusHandle,
|
||||
language_registry: Option<Arc<LanguageRegistry>>,
|
||||
fallback_code_block_language: Option<String>,
|
||||
fallback_code_block_language: Option<LanguageName>,
|
||||
options: Options,
|
||||
copied_code_blocks: HashSet<ElementId>,
|
||||
}
|
||||
|
@ -144,7 +146,7 @@ impl Markdown {
|
|||
pub fn new(
|
||||
source: SharedString,
|
||||
language_registry: Option<Arc<LanguageRegistry>>,
|
||||
fallback_code_block_language: Option<String>,
|
||||
fallback_code_block_language: Option<LanguageName>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
let focus_handle = cx.focus_handle();
|
||||
|
@ -310,9 +312,9 @@ impl Markdown {
|
|||
if let Some(registry) = language_registry.as_ref() {
|
||||
for name in language_names {
|
||||
let language = if !name.is_empty() {
|
||||
registry.language_for_name_or_extension(&name)
|
||||
registry.language_for_name_or_extension(&name).left_future()
|
||||
} else if let Some(fallback) = &fallback {
|
||||
registry.language_for_name_or_extension(fallback)
|
||||
registry.language_for_name(fallback.as_ref()).right_future()
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue