Add fine-grained control for scrollbar diagnostics (#22364)
This PR updates the scrollbar diagnostic setting to provide fine-grained control over which indicators to show, based on severity level. This allows the user to hide lower-severity diagnostics that can otherwise clutter the scrollbar (for example, unused or disabled code). The options are set such that the existing boolean setting has the same effect: when `true` all diagnostics are shown, and when `false` no diagnostics are shown. Closes #22296. Release Notes: - Added fine-grained control of scrollbar diagnostic indicators.
This commit is contained in:
parent
3ac0aef211
commit
f55a3629b0
3 changed files with 111 additions and 9 deletions
|
@ -6,7 +6,7 @@ use crate::{
|
|||
},
|
||||
editor_settings::{
|
||||
CurrentLineHighlight, DoubleClickInMultibuffer, MultiCursorModifier, ScrollBeyondLastLine,
|
||||
ShowScrollbar,
|
||||
ScrollbarDiagnostics, ShowScrollbar,
|
||||
},
|
||||
git::blame::{CommitDetails, GitBlame},
|
||||
hover_popover::{
|
||||
|
@ -1228,7 +1228,7 @@ impl EditorElement {
|
|||
(is_singleton && scrollbar_settings.selected_symbol && (editor.has_background_highlights::<DocumentHighlightRead>() || editor.has_background_highlights::<DocumentHighlightWrite>()))
|
||||
||
|
||||
// Diagnostics
|
||||
(is_singleton && scrollbar_settings.diagnostics && snapshot.buffer_snapshot.has_diagnostics())
|
||||
(is_singleton && scrollbar_settings.diagnostics != ScrollbarDiagnostics::None && snapshot.buffer_snapshot.has_diagnostics())
|
||||
||
|
||||
// Cursors out of sight
|
||||
non_visible_cursors
|
||||
|
@ -4726,13 +4726,38 @@ impl EditorElement {
|
|||
}
|
||||
}
|
||||
|
||||
if scrollbar_settings.diagnostics {
|
||||
if scrollbar_settings.diagnostics != ScrollbarDiagnostics::None {
|
||||
let diagnostics = snapshot
|
||||
.buffer_snapshot
|
||||
.diagnostics_in_range::<_, Point>(
|
||||
Point::zero()..max_point,
|
||||
false,
|
||||
)
|
||||
// Don't show diagnostics the user doesn't care about
|
||||
.filter(|diagnostic| {
|
||||
match (
|
||||
scrollbar_settings.diagnostics,
|
||||
diagnostic.diagnostic.severity,
|
||||
) {
|
||||
(ScrollbarDiagnostics::All, _) => true,
|
||||
(
|
||||
ScrollbarDiagnostics::Error,
|
||||
DiagnosticSeverity::ERROR,
|
||||
) => true,
|
||||
(
|
||||
ScrollbarDiagnostics::Warning,
|
||||
DiagnosticSeverity::ERROR
|
||||
| DiagnosticSeverity::WARNING,
|
||||
) => true,
|
||||
(
|
||||
ScrollbarDiagnostics::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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue