Skip to content

Commit

Permalink
Show error and warning indicators in project panel items (#18182)
Browse files Browse the repository at this point in the history
Closes #5016

Release Notes:

- Add setting to display error and warning indicators in project panel
items.


https://github.com/user-attachments/assets/8f8031e6-ca47-42bf-a7eb-718eb1067f36

---------

Co-authored-by: Thorsten Ball <[email protected]>
Co-authored-by: Danilo Leal <[email protected]>
  • Loading branch information
3 people authored Nov 12, 2024
1 parent a7eb3a9 commit 0a9c78a
Show file tree
Hide file tree
Showing 12 changed files with 262 additions and 30 deletions.
3 changes: 0 additions & 3 deletions assets/icons/indicator_x.svg

This file was deleted.

9 changes: 8 additions & 1 deletion assets/icons/knockouts/triangle_bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/knockouts/triangle_fg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions assets/settings/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,16 @@
/// "never"
"show": null
},
/// Which files containing diagnostic errors/warnings to mark in the project panel.
/// This setting can take the following three values:
///
/// 1. Do not mark any files:
/// "off"
/// 2. Only mark files with errors:
/// "errors"
/// 3. Mark files with errors and warnings:
/// "all"
"show_diagnostics": "all",
// Settings related to indent guides in the project panel.
"indent_guides": {
// When to show indent guides in the project panel.
Expand Down
23 changes: 22 additions & 1 deletion crates/editor/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use gpui::{
use language::{
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, CharKind, Point, SelectionGoal,
};
use lsp::DiagnosticSeverity;
use multi_buffer::AnchorRangeExt;
use project::{
lsp_store::FormatTrigger, project_settings::ProjectSettings, search::SearchQuery, Item as _,
Expand All @@ -39,7 +40,7 @@ use std::{
};
use text::{BufferId, Selection};
use theme::{Theme, ThemeSettings};
use ui::{h_flex, prelude::*, Label};
use ui::{h_flex, prelude::*, IconDecorationKind, Label};
use util::{paths::PathExt, ResultExt, TryFutureExt};
use workspace::item::{BreadcrumbText, FollowEvent};
use workspace::{
Expand Down Expand Up @@ -1515,6 +1516,26 @@ pub fn entry_label_color(selected: bool) -> Color {
}
}

pub fn entry_diagnostic_aware_icon_name_and_color(
diagnostic_severity: Option<DiagnosticSeverity>,
) -> Option<(IconName, Color)> {
match diagnostic_severity {
Some(DiagnosticSeverity::ERROR) => Some((IconName::X, Color::Error)),
Some(DiagnosticSeverity::WARNING) => Some((IconName::Triangle, Color::Warning)),
_ => None,
}
}

pub fn entry_diagnostic_aware_icon_decoration_and_color(
diagnostic_severity: Option<DiagnosticSeverity>,
) -> Option<(IconDecorationKind, Color)> {
match diagnostic_severity {
Some(DiagnosticSeverity::ERROR) => Some((IconDecorationKind::X, Color::Error)),
Some(DiagnosticSeverity::WARNING) => Some((IconDecorationKind::Triangle, Color::Warning)),
_ => None,
}
}

pub fn entry_git_aware_label_color(
git_status: Option<GitFileStatus>,
ignored: bool,
Expand Down
1 change: 1 addition & 0 deletions crates/project_panel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ util.workspace = true
client.workspace = true
worktree.workspace = true
workspace.workspace = true
language.workspace = true

[dev-dependencies]
client = { workspace = true, features = ["test-support"] }
Expand Down
Loading

0 comments on commit 0a9c78a

Please sign in to comment.