Open diagnostics editor faster when fetching cargo diagnostics (#29787)
Follow-up of https://github.com/zed-industries/zed/pull/29706 Release Notes: - N/A
This commit is contained in:
parent
e14d078f8a
commit
33011f2eaf
@ -226,7 +226,7 @@ impl ProjectDiagnosticsEditor {
|
|||||||
cx.observe_global_in::<IncludeWarnings>(window, |this, window, cx| {
|
cx.observe_global_in::<IncludeWarnings>(window, |this, window, cx| {
|
||||||
this.include_warnings = cx.global::<IncludeWarnings>().0;
|
this.include_warnings = cx.global::<IncludeWarnings>().0;
|
||||||
this.diagnostics.clear();
|
this.diagnostics.clear();
|
||||||
this.update_all_diagnostics(window, cx);
|
this.update_all_diagnostics(false, window, cx);
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
cx.observe_release(&cx.entity(), |editor, _, cx| {
|
cx.observe_release(&cx.entity(), |editor, _, cx| {
|
||||||
@ -254,7 +254,7 @@ impl ProjectDiagnosticsEditor {
|
|||||||
},
|
},
|
||||||
_subscription: project_event_subscription,
|
_subscription: project_event_subscription,
|
||||||
};
|
};
|
||||||
this.update_all_diagnostics(window, cx);
|
this.update_all_diagnostics(true, window, cx);
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,13 +346,13 @@ impl ProjectDiagnosticsEditor {
|
|||||||
if self.cargo_diagnostics_fetch.fetch_task.is_some() {
|
if self.cargo_diagnostics_fetch.fetch_task.is_some() {
|
||||||
self.stop_cargo_diagnostics_fetch(cx);
|
self.stop_cargo_diagnostics_fetch(cx);
|
||||||
} else {
|
} else {
|
||||||
self.update_all_diagnostics(window, cx);
|
self.update_all_diagnostics(false, window, cx);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if self.update_excerpts_task.is_some() {
|
if self.update_excerpts_task.is_some() {
|
||||||
self.update_excerpts_task = None;
|
self.update_excerpts_task = None;
|
||||||
} else {
|
} else {
|
||||||
self.update_all_diagnostics(window, cx);
|
self.update_all_diagnostics(false, window, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cx.notify();
|
cx.notify();
|
||||||
@ -371,10 +371,17 @@ impl ProjectDiagnosticsEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_all_diagnostics(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
fn update_all_diagnostics(
|
||||||
|
&mut self,
|
||||||
|
first_launch: bool,
|
||||||
|
window: &mut Window,
|
||||||
|
cx: &mut Context<Self>,
|
||||||
|
) {
|
||||||
let cargo_diagnostics_sources = self.cargo_diagnostics_sources(cx);
|
let cargo_diagnostics_sources = self.cargo_diagnostics_sources(cx);
|
||||||
if cargo_diagnostics_sources.is_empty() {
|
if cargo_diagnostics_sources.is_empty() {
|
||||||
self.update_all_excerpts(window, cx);
|
self.update_all_excerpts(window, cx);
|
||||||
|
} else if first_launch && !self.summary.is_empty() {
|
||||||
|
self.update_all_excerpts(window, cx);
|
||||||
} else {
|
} else {
|
||||||
self.fetch_cargo_diagnostics(Arc::new(cargo_diagnostics_sources), cx);
|
self.fetch_cargo_diagnostics(Arc::new(cargo_diagnostics_sources), cx);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user