Fix some completion docs render delays (#31486)

Closes #31460

While this is now much better than it was, the documentation still
flickers when changing selection. Hoping to fix that, but it will be a
much more involved change. So leaving release notes as "N/A" for now, in
anticipation of the full fix.

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-05-26 22:58:02 -06:00 committed by GitHub
parent 450a10facf
commit 0d3fad7764
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 41 additions and 30 deletions

View file

@ -646,7 +646,7 @@ impl CompletionsMenu {
} => div().child(text.clone()),
CompletionDocumentation::MultiLineMarkdown(parsed) if !parsed.is_empty() => {
let markdown = self.markdown_element.get_or_insert_with(|| {
cx.new(|cx| {
let markdown = cx.new(|cx| {
let languages = editor
.workspace
.as_ref()
@ -656,11 +656,19 @@ impl CompletionsMenu {
.language_at(self.initial_position, cx)
.map(|l| l.name().to_proto());
Markdown::new(SharedString::default(), languages, language, cx)
})
});
// Handles redraw when the markdown is done parsing. The current render is for a
// deferred draw and so was not getting redrawn when `markdown` notified.
cx.observe(&markdown, |_, _, cx| cx.notify()).detach();
markdown
});
markdown.update(cx, |markdown, cx| {
let is_parsing = markdown.update(cx, |markdown, cx| {
markdown.reset(parsed.clone(), cx);
markdown.is_parsing()
});
if is_parsing {
return None;
}
div().child(
MarkdownElement::new(markdown.clone(), hover_markdown_style(window, cx))
.code_block_renderer(markdown::CodeBlockRenderer::Default {