on master help sign in
Turn diagnostics rendering into span injection too
f9cdb2aBlaž Hrastnik
helix-term/src/ui/editor.rs+14−12
@@ -340,6 +340,20 @@ impl EditorView {
340 Box::new(highlights)
340 Box::new(highlights)
341 };
341 };
342
342
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+
343 'outer: for event in highlights {
357 'outer: for event in highlights {
344 match event {
358 match event {
345 HighlightEvent::HighlightStart(span) => {
359 HighlightEvent::HighlightStart(span) => {
@@ -412,18 +426,6 @@ impl EditorView {
412 continue;
426 continue;
413 }
427 }
414
428
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−
427 surface.set_string(
429 surface.set_string(
428 viewport.x + visual_x - view.first_col as u16,
430 viewport.x + visual_x - view.first_col as u16,
429 viewport.y + line,
431 viewport.y + line,
theme.toml+2
@@ -60,6 +60,8 @@
60
60
61"ui.menu.selected" = { fg = "#281733", bg = "#ffffff" } # revolver
61"ui.menu.selected" = { fg = "#281733", bg = "#ffffff" } # revolver
62
62
63+"diagnostic" = { modifiers = ["underlined"] }
64+
63"warning" = "#ffcd1c"
65"warning" = "#ffcd1c"
64"error" = "#f47868"
66"error" = "#f47868"
65"info" = "#6F44F0"
67"info" = "#6F44F0"