Allow to temporarily toggle diagnostics in the editor (#30316)
* Adds a `diagnostics_max_severity: null` editor settings that has previous hardcoded default, `warning` * Make inline diagnostics to inherit this setting by default (can be overridden with its own max_severity setting) * Allows to toggle diagnostics in the editor menu and via new action, `editor::ToggleDiagnostics` Closes https://github.com/zed-industries/zed/issues/4686 Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
parent
9e5d115e72
commit
a8312d623d
12 changed files with 279 additions and 96 deletions
|
@ -54,7 +54,6 @@ use itertools::Itertools;
|
|||
use language::language_settings::{
|
||||
IndentGuideBackgroundColoring, IndentGuideColoring, IndentGuideSettings, ShowWhitespaceSetting,
|
||||
};
|
||||
use lsp::DiagnosticSeverity;
|
||||
use markdown::Markdown;
|
||||
use multi_buffer::{
|
||||
Anchor, ExcerptId, ExcerptInfo, ExpandExcerptDirection, ExpandInfo, MultiBufferPoint,
|
||||
|
@ -64,7 +63,7 @@ use multi_buffer::{
|
|||
use project::{
|
||||
ProjectPath,
|
||||
debugger::breakpoint_store::Breakpoint,
|
||||
project_settings::{self, GitGutterSetting, GitHunkStyleSetting, ProjectSettings},
|
||||
project_settings::{GitGutterSetting, GitHunkStyleSetting, ProjectSettings},
|
||||
};
|
||||
use settings::Settings;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
@ -1474,7 +1473,8 @@ impl EditorElement {
|
|||
});
|
||||
}
|
||||
|
||||
let scrollbar_settings = EditorSettings::get_global(cx).scrollbar;
|
||||
let editor_settings = EditorSettings::get_global(cx);
|
||||
let scrollbar_settings = editor_settings.scrollbar;
|
||||
let show_scrollbars = match scrollbar_settings.show {
|
||||
ShowScrollbar::Auto => {
|
||||
let editor = self.editor.read(cx);
|
||||
|
@ -1796,16 +1796,17 @@ impl EditorElement {
|
|||
if self.editor.read(cx).mode().is_minimap() {
|
||||
return HashMap::default();
|
||||
}
|
||||
let max_severity = ProjectSettings::get_global(cx)
|
||||
|
||||
let max_severity = match ProjectSettings::get_global(cx)
|
||||
.diagnostics
|
||||
.inline
|
||||
.max_severity
|
||||
.map_or(DiagnosticSeverity::HINT, |severity| match severity {
|
||||
project_settings::DiagnosticSeverity::Error => DiagnosticSeverity::ERROR,
|
||||
project_settings::DiagnosticSeverity::Warning => DiagnosticSeverity::WARNING,
|
||||
project_settings::DiagnosticSeverity::Info => DiagnosticSeverity::INFORMATION,
|
||||
project_settings::DiagnosticSeverity::Hint => DiagnosticSeverity::HINT,
|
||||
});
|
||||
.unwrap_or_else(|| self.editor.read(cx).diagnostics_max_severity)
|
||||
.into_lsp()
|
||||
{
|
||||
Some(max_severity) => max_severity,
|
||||
None => return HashMap::default(),
|
||||
};
|
||||
|
||||
let active_diagnostics_group =
|
||||
if let ActiveDiagnostic::Group(group) = &self.editor.read(cx).active_diagnostics {
|
||||
|
@ -1843,11 +1844,11 @@ impl EditorElement {
|
|||
return HashMap::default();
|
||||
}
|
||||
|
||||
let severity_to_color = |sev: &DiagnosticSeverity| match sev {
|
||||
&DiagnosticSeverity::ERROR => Color::Error,
|
||||
&DiagnosticSeverity::WARNING => Color::Warning,
|
||||
&DiagnosticSeverity::INFORMATION => Color::Info,
|
||||
&DiagnosticSeverity::HINT => Color::Hint,
|
||||
let severity_to_color = |sev: &lsp::DiagnosticSeverity| match sev {
|
||||
&lsp::DiagnosticSeverity::ERROR => Color::Error,
|
||||
&lsp::DiagnosticSeverity::WARNING => Color::Warning,
|
||||
&lsp::DiagnosticSeverity::INFORMATION => Color::Info,
|
||||
&lsp::DiagnosticSeverity::HINT => Color::Hint,
|
||||
_ => Color::Error,
|
||||
};
|
||||
|
||||
|
@ -2813,7 +2814,7 @@ impl EditorElement {
|
|||
font: style.text.font(),
|
||||
color: placeholder_color,
|
||||
background_color: None,
|
||||
underline: Default::default(),
|
||||
underline: None,
|
||||
strikethrough: None,
|
||||
};
|
||||
window
|
||||
|
@ -5587,18 +5588,18 @@ impl EditorElement {
|
|||
(ScrollbarDiagnostics::All, _) => true,
|
||||
(
|
||||
ScrollbarDiagnostics::Error,
|
||||
DiagnosticSeverity::ERROR,
|
||||
lsp::DiagnosticSeverity::ERROR,
|
||||
) => true,
|
||||
(
|
||||
ScrollbarDiagnostics::Warning,
|
||||
DiagnosticSeverity::ERROR
|
||||
| DiagnosticSeverity::WARNING,
|
||||
lsp::DiagnosticSeverity::ERROR
|
||||
| lsp::DiagnosticSeverity::WARNING,
|
||||
) => true,
|
||||
(
|
||||
ScrollbarDiagnostics::Information,
|
||||
DiagnosticSeverity::ERROR
|
||||
| DiagnosticSeverity::WARNING
|
||||
| DiagnosticSeverity::INFORMATION,
|
||||
lsp::DiagnosticSeverity::ERROR
|
||||
| lsp::DiagnosticSeverity::WARNING
|
||||
| lsp::DiagnosticSeverity::INFORMATION,
|
||||
) => true,
|
||||
(_, _) => false,
|
||||
}
|
||||
|
@ -5618,9 +5619,9 @@ impl EditorElement {
|
|||
.end
|
||||
.to_display_point(&snapshot.display_snapshot);
|
||||
let color = match diagnostic.diagnostic.severity {
|
||||
DiagnosticSeverity::ERROR => theme.status().error,
|
||||
DiagnosticSeverity::WARNING => theme.status().warning,
|
||||
DiagnosticSeverity::INFORMATION => theme.status().info,
|
||||
lsp::DiagnosticSeverity::ERROR => theme.status().error,
|
||||
lsp::DiagnosticSeverity::WARNING => theme.status().warning,
|
||||
lsp::DiagnosticSeverity::INFORMATION => theme.status().info,
|
||||
_ => theme.status().hint,
|
||||
};
|
||||
ColoredRange {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue