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 |
|--------|--------|
| <img width="800" alt="Screenshot 2024-12-06 at 21 05 13"
src="https://github.com/user-attachments/assets/babf9cc3-b3b0-492e-9748-3e97d96ce90e">
| <img width="800" alt="Screenshot 2024-12-06 at 21 05 24"
src="https://github.com/user-attachments/assets/5247a5f1-55a0-4c56-8aaf-a0cdd115464f">
|


Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2024-12-07 11:00:31 -03:00 committed by GitHub
parent fdc7751457
commit eb3d3eaebf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 17 deletions

View file

@ -569,7 +569,8 @@
// "Neighbour" // "Neighbour"
"activate_on_close": "history", "activate_on_close": "history",
/// Which files containing diagnostic errors/warnings to mark in the tabs. /// 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: /// 1. Do not mark any files:
/// "off" /// "off"
@ -577,7 +578,7 @@
/// "errors" /// "errors"
/// 3. Mark files with errors and warnings: /// 3. Mark files with errors and warnings:
/// "all" /// "all"
"show_diagnostics": "all" "show_diagnostics": "off"
}, },
// Settings related to preview tabs. // Settings related to preview tabs.
"preview_tabs": { "preview_tabs": {

View file

@ -64,9 +64,9 @@ pub enum ClosePosition {
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum ShowDiagnostics { pub enum ShowDiagnostics {
#[default]
Off, Off,
Errors, Errors,
#[default]
All, All,
} }
@ -99,7 +99,7 @@ pub struct ItemSettingsContent {
/// Which files containing diagnostic errors/warnings to mark in the tabs. /// Which files containing diagnostic errors/warnings to mark in the tabs.
/// This setting can take the following three values: /// This setting can take the following three values:
/// ///
/// Default: all /// Default: off
show_diagnostics: Option<ShowDiagnostics>, show_diagnostics: Option<ShowDiagnostics>,
/// Whether to always show the close button on tabs. /// Whether to always show the close button on tabs.
/// ///

View file

@ -2002,12 +2002,8 @@ impl Pane {
let icon = if decorated_icon.is_none() { let icon = if decorated_icon.is_none() {
match item_diagnostic { match item_diagnostic {
Some(&DiagnosticSeverity::ERROR) => { Some(&DiagnosticSeverity::ERROR) => None,
Some(Icon::new(IconName::X).color(Color::Error)) Some(&DiagnosticSeverity::WARNING) => None,
}
Some(&DiagnosticSeverity::WARNING) => {
Some(Icon::new(IconName::Triangle).color(Color::Warning))
}
_ => item.tab_icon(cx).map(|icon| icon.color(Color::Muted)), _ => item.tab_icon(cx).map(|icon| icon.color(Color::Muted)),
} }
.map(|icon| icon.size(IconSize::Small)) .map(|icon| icon.size(IconSize::Small))
@ -2144,13 +2140,17 @@ impl Pane {
.child( .child(
h_flex() h_flex()
.gap_1() .gap_1()
.child(if let Some(decorated_icon) = decorated_icon { .items_center()
div().child(decorated_icon.into_any_element()) .children(
} else if let Some(icon) = icon { std::iter::once(if let Some(decorated_icon) = decorated_icon {
div().mt(px(2.5)).child(icon.into_any_element()) Some(div().child(decorated_icon.into_any_element()))
} else { } else if let Some(icon) = icon {
div() Some(div().child(icon.into_any_element()))
}) } else {
None
})
.flatten(),
)
.child(label), .child(label),
); );