-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Show error and warning indicators in project panel items #18182
Conversation
There was a problem hiding this 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.
if diagnostic_summary.error_count > 0 { | ||
Some((path, Color::Error)) | ||
} else { | ||
None | ||
} |
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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.
Okay I played around a little bit and I have a concrete suggestion: I would not show warnings in the project panel. I think this causes too much unnecessary noise. The status 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. |
I implemented it the way I suggested in the last comment. Looking forward to your feedback on this! demo_new.mov |
@mrnugget can you please take a look at this PR ? Tagging you because of the time zone^^ |
There was a problem hiding this 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 :)
if new_settings.show_diagnostic_errors | ||
&& !project_panel_settings.show_diagnostic_errors | ||
{ | ||
this.update_diagnostics(cx); | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@@ -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>, |
There was a problem hiding this comment.
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.
Here I have an error in the rust-proj, but the go-proj is also marked red.
(cc @bennetbo who found this bug)
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 :)
cc @danilo-leal in case you have thoughts wrt to design |
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.
Let's add the warnings as an option and we will figure out how to make it "pretty" later. |
Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.update_highest_diagnostic_severity( | ||
&project_path, | ||
path_buffer.clone(), | ||
diagnostic_severity, | ||
); |
There was a problem hiding this comment.
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.
*max_diagnostic_severity = | ||
std::cmp::min(*max_diagnostic_severity, diagnostic_severity); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
self.diagnostics = Default::default(); | ||
self.project |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
Hey so this is how it looks like with warnings and the settings as @bennetbo suggested: errors_warnings.movPS: 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 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.
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). |
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. |
Thank you for working on this! It's the only thing keeping me from using Zed as my main editor at this point. 🙂 |
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. |
Co-authored by: Danilo Leal <danilo@zed.dev> Co-authored by: Peter Tripp <peter@zed.dev>
There was a problem hiding this 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.
this PR removed git coloring for icons in the project panel? 🤔 |
@nilskch , @danilo-leal : When set:
How is it displayed? |
@danilo-leal : You are always the best. P.s. |
@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. |
@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. |
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)? |
@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. |
@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! |
Closes #5016
Release Notes:
demo_errors.mov