From eb3d3eaebfdc559105e5f09cec9e162200e3ad1c Mon Sep 17 00:00:00 2001
From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
Date: Sat, 7 Dec 2024 11:00:31 -0300
Subject: [PATCH] Adjust diagnostic in tabs behavior (#21671)
Follow up to https://github.com/zed-industries/zed/pull/21637
After discussing about this feature with the team, we've decided that
diagnostic display in tabs should be: 1) turned off by default, and 2)
only shown when there are file icons. The main reason here being to keep
Zed's UI uncluttered.
This means that you can technically have this setting:
```
"tabs": {
"show_diagnostics": "all"
},
```
...and still don't see any diagnostics because you're missing
`file_icons": true`.
| Error with file icons | Error with no file icons |
|--------|--------|
|
|
|
Release Notes:
- N/A
---
assets/settings/default.json | 5 +++--
crates/workspace/src/item.rs | 4 ++--
crates/workspace/src/pane.rs | 26 +++++++++++++-------------
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/assets/settings/default.json b/assets/settings/default.json
index dd9098e0c038c697d4b798a1879cff215cc9ea0d..20819529ff6047ce29896d4b387d715b7681f849 100644
--- a/assets/settings/default.json
+++ b/assets/settings/default.json
@@ -569,7 +569,8 @@
// "Neighbour"
"activate_on_close": "history",
/// Which files containing diagnostic errors/warnings to mark in the tabs.
- /// This setting can take the following three values:
+ /// Diagnostics are only shown when file icons are also active.
+ /// This setting only works when can take the following three values:
///
/// 1. Do not mark any files:
/// "off"
@@ -577,7 +578,7 @@
/// "errors"
/// 3. Mark files with errors and warnings:
/// "all"
- "show_diagnostics": "all"
+ "show_diagnostics": "off"
},
// Settings related to preview tabs.
"preview_tabs": {
diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs
index 97c27b52a19c4ec5c36c7c4d1872f2ba9f6b1dce..7b9478a9a730a2a8602edf7f60e5269137e2c10b 100644
--- a/crates/workspace/src/item.rs
+++ b/crates/workspace/src/item.rs
@@ -64,9 +64,9 @@ pub enum ClosePosition {
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum ShowDiagnostics {
+ #[default]
Off,
Errors,
- #[default]
All,
}
@@ -99,7 +99,7 @@ pub struct ItemSettingsContent {
/// Which files containing diagnostic errors/warnings to mark in the tabs.
/// This setting can take the following three values:
///
- /// Default: all
+ /// Default: off
show_diagnostics: Option,
/// Whether to always show the close button on tabs.
///
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs
index d213ab630b948af16e258a88bcf52c9698337eaf..a4ca58c11c33d7871d170eecf53f5aa22d1a435c 100644
--- a/crates/workspace/src/pane.rs
+++ b/crates/workspace/src/pane.rs
@@ -2002,12 +2002,8 @@ impl Pane {
let icon = if decorated_icon.is_none() {
match item_diagnostic {
- Some(&DiagnosticSeverity::ERROR) => {
- Some(Icon::new(IconName::X).color(Color::Error))
- }
- Some(&DiagnosticSeverity::WARNING) => {
- Some(Icon::new(IconName::Triangle).color(Color::Warning))
- }
+ Some(&DiagnosticSeverity::ERROR) => None,
+ Some(&DiagnosticSeverity::WARNING) => None,
_ => item.tab_icon(cx).map(|icon| icon.color(Color::Muted)),
}
.map(|icon| icon.size(IconSize::Small))
@@ -2144,13 +2140,17 @@ impl Pane {
.child(
h_flex()
.gap_1()
- .child(if let Some(decorated_icon) = decorated_icon {
- div().child(decorated_icon.into_any_element())
- } else if let Some(icon) = icon {
- div().mt(px(2.5)).child(icon.into_any_element())
- } else {
- div()
- })
+ .items_center()
+ .children(
+ std::iter::once(if let Some(decorated_icon) = decorated_icon {
+ Some(div().child(decorated_icon.into_any_element()))
+ } else if let Some(icon) = icon {
+ Some(div().child(icon.into_any_element()))
+ } else {
+ None
+ })
+ .flatten(),
+ )
.child(label),
);