Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diagnostics: Ensure that clean state is not shown when tab content indicates problems in workspace #25345

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions crates/diagnostics/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use std::{
};
use theme::ActiveTheme;
pub use toolbar_controls::ToolbarControls;
use ui::{h_flex, prelude::*, Icon, IconName, Label};
use ui::{h_flex, prelude::*, Icon, IconName, Label, TintColor};
use util::ResultExt;
use workspace::{
item::{BreadcrumbText, Item, ItemEvent, ItemHandle, TabContentParams},
Expand Down Expand Up @@ -88,15 +88,46 @@ const DIAGNOSTICS_UPDATE_DEBOUNCE: Duration = Duration::from_millis(50);

impl Render for ProjectDiagnosticsEditor {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let child = if self.path_states.is_empty() {
div()
let warning_count = if self.include_warnings {
self.summary.warning_count
} else {
0
};

let child = if warning_count + self.summary.error_count == 0 {
let label = if self.summary.warning_count == 0 {
SharedString::new_static("No problems in workspace")
} else {
SharedString::new_static("No errors in workspace")
};
v_flex()
.gap_1()
.key_context("EmptyPane")
.bg(cx.theme().colors().editor_background)
.flex()
.items_center()
.justify_center()
.items_center()
.size_full()
.child(Label::new("No problems in workspace"))
.child(h_flex().items_center().child(Label::new(label)))
.when(self.summary.warning_count > 0, |this| {
let plural_suffix = if self.summary.warning_count > 1 {
"s"
} else {
""
};
let label = format!(
"Show {} warning{}",
self.summary.warning_count, plural_suffix
);
this.child(
Button::new("diagnostics-show-warning-label", label)
.size(ButtonSize::Compact)
.style(ButtonStyle::Tinted(TintColor::Warning))
.on_click(cx.listener(|this, _, window, cx| {
this.toggle_warnings(&Default::default(), window, cx);
cx.notify();
})),
)
})
} else {
div().size_full().child(self.editor.clone())
};
Expand Down
Loading