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

Show error and warning indicators in project panel items #18182

Merged

Conversation

nilskch
Copy link
Contributor

@nilskch nilskch commented Sep 21, 2024

Closes #5016

Release Notes:

  • Add setting to display error and warning indicators in project panel items.
demo_errors.mov

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Sep 21, 2024
Copy link
Contributor Author

@nilskch nilskch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I love Zed and everything you do for the community! I was missing this feature a lot and many people asked for it and I wanted to give it a try. I hope this is something that you would want for Zed, let me know if I should make any changes.

Comment on lines 450 to 454
if diagnostic_summary.error_count > 0 {
Some((path, Color::Error))
} else {
None
}
Copy link
Contributor Author

@nilskch nilskch Sep 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about doing this:

if diagnostic_summary.error_count > 0 {
    Some((path, Color::Error))
} else if diagnostic_summary.warning_count > 0 {
    Some((path, Color::Warning))
} else {
    None
}

I didn't like that and removed it. We could make this configurable if you want?

@@ -82,6 +82,7 @@ pub struct ProjectPanel {
show_scrollbar: bool,
scrollbar_drag_thumb_offset: Rc<Cell<Option<f32>>>,
hide_scrollbar_task: Option<Task<()>>,
diagnostic_error_colors: HashMap<PathBuf, Color>,
Copy link
Contributor Author

@nilskch nilskch Sep 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we do want to support showing warnings in the project panel, this should be a HashMap. If we only want to show errors we can make this a HashSet and not store the colors.

@nilskch
Copy link
Contributor Author

nilskch commented Sep 22, 2024

Okay I played around a little bit and I have a concrete suggestion:
Let's add a "show_diagnostic_errors" bool property in the "project_panel" object in the settings.json. I would use a default value of true, but happy to make it false if you like it better.

I would not show warnings in the project panel. I think this causes too much unnecessary noise. The status GitFileStatus::Modified paints the items with the color Color::Modified which is very similar to Color::Warning (at least in the theme One Light) and this is very confusing.

If people want to display warnings as well, I am happy to make a follow-up PR but I honestly do not think someone wants this.

I will implement this and add the docs next week if you think this would be a good add.

@nilskch
Copy link
Contributor Author

nilskch commented Sep 23, 2024

I implemented it the way I suggested in the last comment. Looking forward to your feedback on this!

demo_new.mov

@nilskch
Copy link
Contributor Author

nilskch commented Sep 24, 2024

@mrnugget can you please take a look at this PR ? Tagging you because of the time zone^^

Copy link
Member

@mrnugget mrnugget left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Left a bunch of comments :)

Comment on lines 294 to 298
if new_settings.show_diagnostic_errors
&& !project_panel_settings.show_diagnostic_errors
{
this.update_diagnostics(cx);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you disable it? Don't you then have to reset self.diagnostic_error_paths to be empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrnugget my thought was that self.diagnostic_error_paths is not used and updated once you enable the setting again and therefore it's not necessary to reset it. On the other hand this wastes memory, I will reset it.

crates/project_panel/src/project_panel_settings.rs Outdated Show resolved Hide resolved
@@ -82,6 +82,7 @@ pub struct ProjectPanel {
show_scrollbar: bool,
scrollbar_drag_thumb_offset: Rc<Cell<Option<f32>>>,
hide_scrollbar_task: Option<Task<()>>,
diagnostic_error_paths: HashSet<PathBuf>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need something like HashMap<WorktreeId, HashSet<PathBuf>, otherwise you'll have global diagnostic errors, even if they appear in a different worktree.

Example:
screenshot-2024-09-24-15 00 32@2x

Here I have an error in the rust-proj, but the go-proj is also marked red.

(cc @bennetbo who found this bug)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know you can do this in Zed, thanks for flagging!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Takes a while to digest that and then you see it everywhere :)

@mrnugget
Copy link
Member

cc @danilo-leal in case you have thoughts wrt to design

@bennetbo
Copy link
Contributor

If people want to display warnings as well, I am happy to make a follow-up PR but I honestly do not think someone wants this.\

I'd like to have this and would prefer to add this in this PR as well, so that we do not have to break the settings right after this is released.
Maybe we could have a setting like (not sure about the names of the enum variants):
"show_diagnostics": "off/all/errors"

I would not show warnings in the project panel. I think this causes too much unnecessary noise. The status GitFileStatus::Modified paints the items with the color Color::Modified which is very similar to Color::Warning (at least in the theme One Light) and this is very confusing.

Let's add the warnings as an option and we will figure out how to make it "pretty" later.

Copy link
Contributor Author

@nilskch nilskch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrnugget @bennetbo thanks for the feedback! I think I addressed your comments now. Let me know how you want the settings to look like and what defaults we should use.

crates/project_panel/src/project_panel.rs Show resolved Hide resolved
crates/project_panel/src/project_panel.rs Outdated Show resolved Hide resolved
Comment on lines 475 to 479
self.update_highest_diagnostic_severity(
&project_path,
path_buffer.clone(),
diagnostic_severity,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here is necessary to also include the root directory of the worktree. We need the empty buffer in the HashMap as well.

Comment on lines 501 to 502
*max_diagnostic_severity =
std::cmp::min(*max_diagnostic_severity, diagnostic_severity);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little bit confusing, but DiagnosticSeverity::ERROR < DiagnosticSeverity::WARNING and I think errors should overshadow warnings here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: renamed to strongest_diagnostic_severity

Comment on lines 460 to 461
self.diagnostics = Default::default();
self.project
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better here to store everything in a local HashMap first and assign the local variable at the end to self.diagnostics?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that's how I'd do it, would make the code nicer, IMHO

@nilskch
Copy link
Contributor Author

nilskch commented Sep 25, 2024

Hey so this is how it looks like with warnings and the settings as @bennetbo suggested:

errors_warnings.mov

PS: I changed my GPG key last night and apparently you should not remove the old public key from your profile, otherwise old commits show up as unverified. It's still me, just wiser.

@mrnugget
Copy link
Member

One thing that I'm now wondering about: how will a modified file look different from a file with warnings? Right now, modified files look like this:
screenshot-2024-09-25-10 15 52@2x

That's also the has-a-warning style, no?

@nilskch
Copy link
Contributor Author

nilskch commented Sep 25, 2024

@mrnugget in the last comment I posted a video where you can see the difference when I changed the settings. In the theme "One Light" the warning color is a lot brighter than the modified color. Tbh, I am not the biggest fan of having both, warnings and git modified.

Let's add the warnings as an option and we will figure out how to make it "pretty" later.

Not sure how much effort it is to make it "pretty", but maybe we should do that before we introduce this feature? The contrast of the warnings color is very bad for the selected file (see video).

@danilo-leal
Copy link
Contributor

I'd avoid using only colors for these statuses—different themes will have different color qualities, and relying only on them can be very tricky. We can't guarantee that it will look great in all themes, and folks with any visual impairments can have an even harder time!

That said, I'd consider adding the same icons we display on the status bar for errors and warnings and simple dot indicators for the Git-related statuses (added & modified) to the project item. I'd also add tooltips to them.

image

@zackangelo
Copy link

Thank you for working on this! It's the only thing keeping me from using Zed as my main editor at this point. 🙂

@nervenes
Copy link
Contributor

nervenes commented Nov 3, 2024

I really like the design, but as far as I understood, the Zed team is working on horizontal scrolling in the project panel at the moment and I do not think the A/M icons would work with that. I think it is best to wait for feedback from the Zed team before implementing more designs :)

Hey, i've just created a continuation PR for the git symbols in the project panel (and editor tabs), might want to check it out: #20134

My two cents on the design here, is adding the existing error/warning icons to the end slot, where error takes precedence over warning, these icons should be additional to the git symbols i'm adding i.e not to replace them, they could be on the left of U/M/C.

For coloring, red for error and yellow for warning could take precedence over the git coloring, as the entries will have their respective git symbols if my PR gets merged. Project diagnostics overall sounds to me should have higher priority, i think this is how VSCode and Xcode also does it.

This would go in hand with the changes i've done in my PR that i mentioned.

Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this PR for now; feeling good about it! Thanks so much @nilskch and everyone else for the continued effort & contribution! We'll tackle any upcoming feedback iteratively on future PRs.

@danilo-leal danilo-leal merged commit 0a9c78a into zed-industries:main Nov 12, 2024
11 checks passed
@nervenes
Copy link
Contributor

this PR removed git coloring for icons in the project panel? 🤔

@nilskch nilskch deleted the feat/highlight-errors-in-project-panel branch November 13, 2024 12:22
@Angelk90
Copy link
Contributor

@nilskch , @danilo-leal :

When set:

"project_panel": {
    "folder_icons": false
  }

How is it displayed?

@danilo-leal
Copy link
Contributor

@Angelk90 like so. You'll be able to get these changes on the upcoming version this week!

Screenshot 2024-11-13 at 12 44 29

@nervenes yeah, at least by default, we're aiming to have Git status only affect panel item labels for now. The icons also being affected should probably be a setting you'd turn on.

@Angelk90
Copy link
Contributor

@danilo-leal : You are always the best.

P.s.
How do you make zed screenshots without background?

@nervenes
Copy link
Contributor

nervenes commented Nov 13, 2024

@danilo-leal i see, i know this is just an initial implementation but i think there are some things that can be cleared up, im trying to think from the average users perspective, but y'all know the best :>

if i were new, and the project panel showed me warning and error indicators on the file icon for diagnostics, and the file name was yellow (modified) or red (conflict) for git, and i solved the warning/error diagnostic problem but the filename is still colored yellow/red (for git) would confuse me, and vice versa if i solved a git problem and the yellow/red filename color went away while the warning/error indicator for diagnostics persisted. what's even more confusing now is that diagnostics coloring and git coloring for filenames take mixed priority, error diagnostics take highest priority, git takes second priority than warning diagnostics, and i know this because i've followed through the development of this but will the regular user know this?

if this is the path that is wanted, then maybe it would be better to either pick diagnostics or git (not both) for coloring? so i'd imagine with coloring mode to be set to diagnostics, it would color filenames either red or yellow, with no conflicting git colors, and git symbols (when/if merged) will be used to infer git information. or the opposite, that git coloring is enabled and you'd only infer diagnostics from the indicators (but the problem here is that the indicators are colored and small, so it still may not be clear to the user what it's actually for). i would personally recommend the former.

this is pushing me back on my git aware implementations for project panel entries and editor tabs, and i don't know what the vision/plan is here.

@danilo-leal
Copy link
Contributor

@nervenes I just pushed a PR earlier today that I think goes along your latter suggestion #20600. I hear you about the icons being potentially not clear, though. I guess we could solve it via a tooltip. Like, if you hover the file with the X error icon, you could see something like "There's an error" or a better label.

@nervenes
Copy link
Contributor

nervenes commented Nov 13, 2024

additionally, maybe clicking on the tooltip could take you to the particular error/warning in the diagnostic panel? also, is there any other place i could have a discussion with you, maybe any of the channels in the discord channel? i'd like to ask some questions about the git symbols, or should i open up an empty pr (that i'll later use for the implementation)?

@hawkinsonb
Copy link

@danilo-leal @nervenes Why not strike-through the filename for a git removal and use a darker red color if you need a color indicator? That way it very clearly separates it from diagnostics red, while adding a visual cue that a file was removed. This would accomplish the separation of functionality you are looking for while making the UX much nicer and explicit.

@danilo-leal
Copy link
Contributor

@nervenes interesting idea! Hit me up on Zed's Discord. You can fine me there!

@hawkinsonb curious to explore that, yeah. Thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show errors/warning counts in tree view