diff --git a/assets/settings/default.json b/assets/settings/default.json index 9f4f2dc34c0d91..aaf2748c5e4af3 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -258,6 +258,12 @@ "selected_symbol": true, // Whether to show diagnostic indicators in the scrollbar. "diagnostics": true, + // Which diagnostic indicator levels to show in the scrollbar, if indicators are enabled: + // - "error": show only errors + // - "warning": show only errors and warnings + // - "information": show only errors, warnings, and information + // - "all": show all diagnostics + "diagnostic_level": "all", /// Forcefully enable or disable the scrollbar for each axis "axes": { /// When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings. diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs index d5cbb3e23237de..5352733fc26333 100644 --- a/crates/editor/src/editor_settings.rs +++ b/crates/editor/src/editor_settings.rs @@ -106,6 +106,7 @@ pub struct Scrollbar { pub selected_symbol: bool, pub search_results: bool, pub diagnostics: bool, + pub diagnostic_level: ScrollbarDiagnosticLevel, pub cursors: bool, pub axes: ScrollbarAxes, } @@ -150,6 +151,22 @@ pub struct ScrollbarAxes { pub vertical: bool, } +/// Which diagnostic indicator levels to show in the scrollbar. +/// +/// Default: all +#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] +#[serde(rename_all = "lowercase")] +pub enum ScrollbarDiagnosticLevel { + /// Show all diagnostic levels: hint, information, warnings, error. + All, + /// Show only the following diagnostic levels: information, warning, error. + Information, + /// Show only the following diagnostic levels: warning, error. + Warning, + /// Show only the following diagnostic level: error. + Error, +} + /// The key to use for adding multiple cursors /// /// Default: alt @@ -352,6 +369,10 @@ pub struct ScrollbarContent { /// /// Default: true pub diagnostics: Option, + /// Which diagnostic indicators to show in the scrollbar. + /// + /// Default: all + pub diagnostic_level: Option, /// Whether to show cursor positions in the scrollbar. /// /// Default: true diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index af89945f4f0d10..26a2d9086eca01 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -6,7 +6,7 @@ use crate::{ }, editor_settings::{ CurrentLineHighlight, DoubleClickInMultibuffer, MultiCursorModifier, ScrollBeyondLastLine, - ShowScrollbar, + ScrollbarDiagnosticLevel, ShowScrollbar, }, git::blame::{CommitDetails, GitBlame}, hover_popover::{ @@ -4664,6 +4664,31 @@ impl EditorElement { Point::zero()..max_point, false, ) + // Don't show diagnostics the user doesn't care about + .filter(|diagnostic| { + match ( + scrollbar_settings.diagnostic_level, + diagnostic.diagnostic.severity, + ) { + (ScrollbarDiagnosticLevel::All, _) => true, + ( + ScrollbarDiagnosticLevel::Error, + DiagnosticSeverity::ERROR, + ) => true, + ( + ScrollbarDiagnosticLevel::Warning, + DiagnosticSeverity::ERROR + | DiagnosticSeverity::WARNING, + ) => true, + ( + ScrollbarDiagnosticLevel::Information, + DiagnosticSeverity::ERROR + | DiagnosticSeverity::WARNING + | DiagnosticSeverity::INFORMATION, + ) => true, + (_, _) => false, + } + }) // We want to sort by severity, in order to paint the most severe diagnostics last. .sorted_by_key(|diagnostic| { std::cmp::Reverse(diagnostic.diagnostic.severity)