diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2024-06-12 20:58:28 +0200 |
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-13 16:23:34 +0200 |
| commit | 657c51636080e9b3c9c2215d05b08f3cccf68e70 (patch) | |
| tree | 63acf2cae604e139443575bf94aecc934b2068ed /src/error.cpp | |
| parent | 603581aa5358d34ddd899bc961c1efc6dce72820 (diff) | |
Pad ‘^~~~^’-style diagnostic ranges properly
Diffstat (limited to 'src/error.cpp')
| -rw-r--r-- | src/error.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/error.cpp b/src/error.cpp index 03d96219b..5a4cb6a0c 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -323,8 +323,13 @@ gb_internal isize show_error_on_line(TokenPos const &pos, TokenPos end) { } error_out("\n\t"); - for (i32 i = 0; i < offset; i++) { - error_out(" "); + for (i32 rune_width, off = 0; off < offset; off += rune_width) { + i32 rune; + rune_width = cast(i32)utf8proc_iterate((u8 const *)line_text + off, line_len - off, &rune); + int w = utf8proc_charwidth(rune); + if (w > 0) { + error_out("%.*s", w, " "); + } } terminal_set_colours(TerminalStyle_Bold, TerminalColour_Green); |