mirror of https://github.com/helix-editor/helix
Turn diagnostics rendering into span injection too
parent
90d675fb15
commit
f9cdb2afe2
|
@ -340,6 +340,20 @@ impl EditorView {
|
||||||
Box::new(highlights)
|
Box::new(highlights)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// diagnostic injection
|
||||||
|
let diagnostic_scope = theme.find_scope_index("diagnostic").unwrap_or(cursor_scope);
|
||||||
|
let spans_ = doc
|
||||||
|
.diagnostics()
|
||||||
|
.iter()
|
||||||
|
.map(|diagnostic| {
|
||||||
|
(
|
||||||
|
diagnostic_scope,
|
||||||
|
diagnostic.range.start..diagnostic.range.end,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let highlights = Box::new(merge(highlights, spans_));
|
||||||
|
|
||||||
'outer: for event in highlights {
|
'outer: for event in highlights {
|
||||||
match event {
|
match event {
|
||||||
HighlightEvent::HighlightStart(span) => {
|
HighlightEvent::HighlightStart(span) => {
|
||||||
|
@ -412,18 +426,6 @@ impl EditorView {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ugh,interleave highlight spans with diagnostic spans
|
|
||||||
let is_diagnostic = doc.diagnostics().iter().any(|diagnostic| {
|
|
||||||
diagnostic.range.start <= char_index
|
|
||||||
&& diagnostic.range.end > char_index
|
|
||||||
});
|
|
||||||
|
|
||||||
let style = if is_diagnostic {
|
|
||||||
style.add_modifier(Modifier::UNDERLINED)
|
|
||||||
} else {
|
|
||||||
style
|
|
||||||
};
|
|
||||||
|
|
||||||
surface.set_string(
|
surface.set_string(
|
||||||
viewport.x + visual_x - view.first_col as u16,
|
viewport.x + visual_x - view.first_col as u16,
|
||||||
viewport.y + line,
|
viewport.y + line,
|
||||||
|
|
|
@ -60,6 +60,8 @@
|
||||||
|
|
||||||
"ui.menu.selected" = { fg = "#281733", bg = "#ffffff" } # revolver
|
"ui.menu.selected" = { fg = "#281733", bg = "#ffffff" } # revolver
|
||||||
|
|
||||||
|
"diagnostic" = { modifiers = ["underlined"] }
|
||||||
|
|
||||||
"warning" = "#ffcd1c"
|
"warning" = "#ffcd1c"
|
||||||
"error" = "#f47868"
|
"error" = "#f47868"
|
||||||
"info" = "#6F44F0"
|
"info" = "#6F44F0"
|
||||||
|
|
Loading…
Reference in New Issue