on master help sign in
Turn diagnostics rendering into span injection too
commitf9cdb2afe29045723d2ad14eaea371eddf3107fe authorBlaž Hrastnik <blaz@mxxn.io> dateSun 27 Jun 2021, 00:14 (5 years ago) parent90d675f
2 files changed+16−12
helix-term/src/ui/editor.rs+14−12 theme.toml+2
helix-term/src/ui/editor.rs+14−12
@@ -340,6 +340,20 @@ impl EditorView {
340340 Box::new(highlights)
341341 };
342342
343+ // diagnostic injection
344+ let diagnostic_scope = theme.find_scope_index("diagnostic").unwrap_or(cursor_scope);
345+ let spans_ = doc
346+ .diagnostics()
347+ .iter()
348+ .map(|diagnostic| {
349+ (
350+ diagnostic_scope,
351+ diagnostic.range.start..diagnostic.range.end,
352+ )
353+ })
354+ .collect();
355+ let highlights = Box::new(merge(highlights, spans_));
356+
343357 'outer: for event in highlights {
344358 match event {
345359 HighlightEvent::HighlightStart(span) => {
@@ -412,18 +426,6 @@ impl EditorView {
412426 continue;
413427 }
414428
415− // ugh,interleave highlight spans with diagnostic spans
416− let is_diagnostic = doc.diagnostics().iter().any(|diagnostic| {
417− diagnostic.range.start <= char_index
418− && diagnostic.range.end > char_index
419− });
420−
421− let style = if is_diagnostic {
422− style.add_modifier(Modifier::UNDERLINED)
423− } else {
424− style
425− };
426−
427429 surface.set_string(
428430 viewport.x + visual_x - view.first_col as u16,
429431 viewport.y + line,
theme.toml+2
@@ -60,6 +60,8 @@
6060
6161"ui.menu.selected" = { fg = "#281733", bg = "#ffffff" } # revolver
6262
63+"diagnostic" = { modifiers = ["underlined"] }
64+
6365"warning" = "#ffcd1c"
6466"error" = "#f47868"
6567"info" = "#6F44F0"