Merge branch 'project-diagnostics-pinned-tab' into style-project-diagnostics
This commit is contained in:
commit
c9b4bb78f2
13 changed files with 118 additions and 70 deletions
|
@ -13,6 +13,7 @@ editor = { path = "../editor" }
|
|||
language = { path = "../language" }
|
||||
gpui = { path = "../gpui" }
|
||||
project = { path = "../project" }
|
||||
theme = { path = "../theme" }
|
||||
util = { path = "../util" }
|
||||
workspace = { path = "../workspace" }
|
||||
postage = { version = "0.4", features = ["futures-traits"] }
|
||||
|
|
|
@ -17,7 +17,7 @@ use language::{
|
|||
Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Point, Selection, SelectionGoal,
|
||||
};
|
||||
use postage::watch;
|
||||
use project::{Project, ProjectPath};
|
||||
use project::{DiagnosticSummary, Project, ProjectPath};
|
||||
use std::{
|
||||
any::{Any, TypeId},
|
||||
cmp::Ordering,
|
||||
|
@ -57,6 +57,7 @@ struct ProjectDiagnosticsEditor {
|
|||
model: ModelHandle<ProjectDiagnostics>,
|
||||
workspace: WeakViewHandle<Workspace>,
|
||||
editor: ViewHandle<Editor>,
|
||||
summary: DiagnosticSummary,
|
||||
excerpts: ModelHandle<MultiBuffer>,
|
||||
path_states: Vec<PathState>,
|
||||
paths_to_update: BTreeSet<ProjectPath>,
|
||||
|
@ -132,6 +133,7 @@ impl ProjectDiagnosticsEditor {
|
|||
project::Event::DiskBasedDiagnosticsFinished => {
|
||||
let paths = mem::take(&mut this.paths_to_update);
|
||||
this.update_excerpts(paths, cx);
|
||||
cx.emit(Event::TitleChanged)
|
||||
}
|
||||
project::Event::DiagnosticsUpdated(path) => {
|
||||
this.paths_to_update.insert(path.clone());
|
||||
|
@ -147,13 +149,11 @@ impl ProjectDiagnosticsEditor {
|
|||
cx.subscribe(&editor, |_, _, event, cx| cx.emit(*event))
|
||||
.detach();
|
||||
|
||||
let paths_to_update = project
|
||||
.read(cx)
|
||||
.diagnostic_summaries(cx)
|
||||
.map(|e| e.0)
|
||||
.collect();
|
||||
let project = project.read(cx);
|
||||
let paths_to_update = project.diagnostic_summaries(cx).map(|e| e.0).collect();
|
||||
let this = Self {
|
||||
model,
|
||||
summary: project.diagnostic_summary(cx),
|
||||
workspace,
|
||||
excerpts,
|
||||
editor,
|
||||
|
@ -556,8 +556,38 @@ impl workspace::ItemView for ProjectDiagnosticsEditor {
|
|||
self.model.clone()
|
||||
}
|
||||
|
||||
fn title(&self, _: &AppContext) -> String {
|
||||
"Project Diagnostics".to_string()
|
||||
fn tab_content(&self, style: &theme::Tab, _: &AppContext) -> ElementBox {
|
||||
let theme = &self.settings.borrow().theme.project_diagnostics;
|
||||
let icon_width = theme.tab_icon_width;
|
||||
let icon_spacing = theme.tab_icon_spacing;
|
||||
let summary_spacing = theme.tab_summary_spacing;
|
||||
Flex::row()
|
||||
.with_children([
|
||||
Svg::new("icons/no.svg")
|
||||
.with_color(style.label.text.color)
|
||||
.constrained()
|
||||
.with_width(icon_width)
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_margin_right(icon_spacing)
|
||||
.named("no-icon"),
|
||||
Label::new(self.summary.error_count.to_string(), style.label.clone())
|
||||
.aligned()
|
||||
.boxed(),
|
||||
Svg::new("icons/warning.svg")
|
||||
.with_color(style.label.text.color)
|
||||
.constrained()
|
||||
.with_width(icon_width)
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_margin_left(summary_spacing)
|
||||
.with_margin_right(icon_spacing)
|
||||
.named("warn-icon"),
|
||||
Label::new(self.summary.warning_count.to_string(), style.label.clone())
|
||||
.aligned()
|
||||
.boxed(),
|
||||
])
|
||||
.boxed()
|
||||
}
|
||||
|
||||
fn project_path(&self, _: &AppContext) -> Option<project::ProjectPath> {
|
||||
|
@ -603,10 +633,7 @@ impl workspace::ItemView for ProjectDiagnosticsEditor {
|
|||
}
|
||||
|
||||
fn should_update_tab_on_event(event: &Event) -> bool {
|
||||
matches!(
|
||||
event,
|
||||
Event::Saved | Event::Dirtied | Event::FileHandleChanged
|
||||
)
|
||||
matches!(event, Event::Saved | Event::Dirtied | Event::TitleChanged)
|
||||
}
|
||||
|
||||
fn clone_on_split(&self, cx: &mut ViewContext<Self>) -> Option<Self>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue