mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 10:20:51 +00:00
Parallelize diagnostics filling, add more logs
This commit is contained in:
parent
ff1d692e46
commit
fdcb907644
3 changed files with 35 additions and 17 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2459,6 +2459,7 @@ dependencies = [
|
||||||
"client",
|
"client",
|
||||||
"collections",
|
"collections",
|
||||||
"editor",
|
"editor",
|
||||||
|
"futures 0.3.28",
|
||||||
"gpui",
|
"gpui",
|
||||||
"language",
|
"language",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
@ -22,6 +22,7 @@ workspace = { path = "../workspace" }
|
||||||
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
futures.workspace = true
|
||||||
schemars.workspace = true
|
schemars.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_derive.workspace = true
|
serde_derive.workspace = true
|
||||||
|
|
|
@ -2,7 +2,7 @@ pub mod items;
|
||||||
mod project_diagnostics_settings;
|
mod project_diagnostics_settings;
|
||||||
mod toolbar_controls;
|
mod toolbar_controls;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::{Context, Result};
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use editor::{
|
use editor::{
|
||||||
diagnostic_block_renderer,
|
diagnostic_block_renderer,
|
||||||
|
@ -11,6 +11,7 @@ use editor::{
|
||||||
scroll::autoscroll::Autoscroll,
|
scroll::autoscroll::Autoscroll,
|
||||||
Editor, ExcerptId, ExcerptRange, MultiBuffer, ToOffset,
|
Editor, ExcerptId, ExcerptRange, MultiBuffer, ToOffset,
|
||||||
};
|
};
|
||||||
|
use futures::future::try_join_all;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, fonts::TextStyle, serde_json, AnyViewHandle, AppContext, Entity,
|
actions, elements::*, fonts::TextStyle, serde_json, AnyViewHandle, AppContext, Entity,
|
||||||
ModelHandle, Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
ModelHandle, Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||||
|
@ -277,25 +278,40 @@ impl ProjectDiagnosticsEditor {
|
||||||
}
|
}
|
||||||
paths_to_recheck.extend(old_diagnostics.into_iter().flat_map(|(_, paths)| paths));
|
paths_to_recheck.extend(old_diagnostics.into_iter().flat_map(|(_, paths)| paths));
|
||||||
|
|
||||||
|
if paths_to_recheck.is_empty() {
|
||||||
|
log::debug!("No paths to recheck for language server {language_server_id:?}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log::debug!(
|
||||||
|
"Rechecking {} paths for language server {:?}",
|
||||||
|
paths_to_recheck.len(),
|
||||||
|
language_server_id
|
||||||
|
);
|
||||||
let project = self.project.clone();
|
let project = self.project.clone();
|
||||||
cx.spawn(|this, mut cx| {
|
cx.spawn(|this, mut cx| {
|
||||||
async move {
|
async move {
|
||||||
let mut changed = false;
|
let _ = try_join_all(paths_to_recheck.into_iter().map(|path| {
|
||||||
for path in paths_to_recheck {
|
let mut cx = cx.clone();
|
||||||
let buffer = project
|
let project = project.clone();
|
||||||
.update(&mut cx, |project, cx| project.open_buffer(path.clone(), cx))
|
async move {
|
||||||
.await?;
|
let buffer = project
|
||||||
this.update(&mut cx, |this, cx| {
|
.update(&mut cx, |project, cx| project.open_buffer(path.clone(), cx))
|
||||||
this.populate_excerpts(path, language_server_id, buffer, cx);
|
.await
|
||||||
changed = true;
|
.with_context(|| format!("opening buffer for path {path:?}"))?;
|
||||||
})?;
|
this.update(&mut cx, |this, cx| {
|
||||||
}
|
this.populate_excerpts(path, language_server_id, buffer, cx);
|
||||||
if changed {
|
})
|
||||||
this.update(&mut cx, |this, cx| {
|
.context("missing project")?;
|
||||||
this.summary = this.project.read(cx).diagnostic_summary(cx);
|
anyhow::Ok(())
|
||||||
cx.emit(Event::TitleChanged);
|
}
|
||||||
})?;
|
}))
|
||||||
}
|
.await?;
|
||||||
|
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
|
this.summary = this.project.read(cx).diagnostic_summary(cx);
|
||||||
|
cx.emit(Event::TitleChanged);
|
||||||
|
})?;
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
}
|
}
|
||||||
.log_err()
|
.log_err()
|
||||||
|
|
Loading…
Reference in a new issue