Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

markdown_preview: Fix slow checkbox check/uncheck UI updates (#48633)

Wesley Weisenberger0e83147823f9
diff --git a/crates/markdown_preview/src/markdown_preview_view.rs b/crates/markdown_preview/src/markdown_preview_view.rs
index 79bd7f33290..d6e4a78fd8a 100644
--- a/crates/markdown_preview/src/markdown_preview_view.rs
+++ b/crates/markdown_preview/src/markdown_preview_view.rs
@@ -312,6 +312,10 @@ impl MarkdownPreviewView {
cx: &mut Context<Self>,
) {
if let Some(state) = &self.active_editor {
+ // if there is already a task to update the ui and the current task is also debounced (not high priority), do nothing
+ if wait_for_debounce && self.parsing_markdown_task.is_some() {
+ return;
+ }
self.parsing_markdown_task = Some(self.parse_markdown_in_background(
wait_for_debounce,
state.editor.clone(),
@@ -355,6 +359,7 @@ impl MarkdownPreviewView {
let scroll_top = view.list_state.logical_scroll_top();
view.list_state.reset(markdown_blocks_count);
view.list_state.scroll_to(scroll_top);
+ view.parsing_markdown_task = None;
cx.notify();
})
})