Skip to content

Commit

Permalink
feat: support setting a default style for the inline diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics committed Feb 24, 2023
1 parent 6ddc531 commit a8b5d86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,10 @@ These scopes are used for theming the editor interface.
| `ui.text.focus` | |
| `ui.text.inactive` | Same as `ui.text` but when the text is inactive (e.g. suggestions) |
| `ui.text.info` | The key: command text in `ui.popup.info` boxes |
| `ui.virtual.diagnostics` | Default style for inline diagnostics lines (notably control the background) |
| `ui.virtual.indent-guide` | Vertical indent width guides |
| `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][editor-section]) |
| `ui.virtual.whitespace` | Visible whitespace characters |
| `ui.virtual.indent-guide` | Vertical indent width guides |
| `ui.virtual.wrap` | Soft-wrap indicator (see the [`editor.soft-wrap` config][editor-section]) |
| `ui.menu` | Code and command completion menus |
| `ui.menu.selected` | Selected autocomplete item |
Expand Down
17 changes: 15 additions & 2 deletions helix-term/src/ui/editor/diagnostics_annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub fn inline_diagnostics_decorator(
theme: &Theme,
text_annotations: &TextAnnotations,
) -> Box<dyn LineDecoration> {
let whole_view_aera = view.area;
let background = theme.get("ui.virtual.diagnostics");

let hint = theme.get("hint");
let info = theme.get("info");
let warning = theme.get("warning");
Expand Down Expand Up @@ -226,8 +229,18 @@ pub fn inline_diagnostics_decorator(
// c. Is just one line.
// d. Is not an overlap.

let lines_offset = text.lines().count();
pos_y -= lines_offset as u16;
let lines_offset = text.lines().count() as u16;
pos_y -= lines_offset;

// Use `view` since it's the whole outer view instead of just the inner area so that the background
// is also applied to the gutters and other elements that are not in the editable part of the document
let diag_area = Rect::new(
whole_view_aera.x,
pos_y + 1,
whole_view_aera.width,
lines_offset,
);
renderer.surface.set_style(diag_area, background);

for (offset, line) in text.lines().enumerate() {
let mut pos_x = viewport.x;
Expand Down

0 comments on commit a8b5d86

Please sign in to comment.