Skip to content

Commit

Permalink
Adds a diagnostics severity marker to diagnostics picker
Browse files Browse the repository at this point in the history
Co-authored-by: Poliorcetics <[email protected]>
  • Loading branch information
zummenix and poliorcetics committed Jun 18, 2023
1 parent d5af603 commit db29152
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ struct PickerDiagnostic {
offset_encoding: OffsetEncoding,
}

impl PickerDiagnostic {
fn severity_marker(&self) -> &'static str {
let empty_space = " ";
self.diag.severity.map_or(empty_space, |s| match s {
DiagnosticSeverity::HINT => "H ",
DiagnosticSeverity::INFORMATION => "I ",
DiagnosticSeverity::WARNING => "W ",
DiagnosticSeverity::ERROR => "E ",
_ => empty_space,
})
}
}

impl ui::menu::Item for PickerDiagnostic {
type Data = (DiagnosticStyles, DiagnosticsFormat);

Expand Down Expand Up @@ -178,6 +191,7 @@ impl ui::menu::Item for PickerDiagnostic {
};

Spans::from(vec![
Span::raw(self.severity_marker()),
Span::raw(path),
Span::styled(&self.diag.message, style),
Span::styled(code, style),
Expand Down

0 comments on commit db29152

Please sign in to comment.