From 202349d88f5c568f651ade1569ed192cd4be321c Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 11 Feb 2026 16:49:14 +0100 Subject: [PATCH] - Improved underlining errors/warnings when unicode is used. #2887 --- releasenotes.md | 1 + src/compiler/diagnostics.c | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/releasenotes.md b/releasenotes.md index bd65d29b3..fff471612 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -30,6 +30,7 @@ - Flag `--cpu-flags` doesn't work if the first item is an exclusion. #2905 - Reallocating overaligned memory with the LibcAllocator was unsafe. - Using [] or .foo on $$ functions would not raise error but instead crash +- Improved underlining errors/warnings when unicode is used. #2887 ## 0.7.9 Change list diff --git a/src/compiler/diagnostics.c b/src/compiler/diagnostics.c index 8cf14a327..7ac4f4977 100644 --- a/src/compiler/diagnostics.c +++ b/src/compiler/diagnostics.c @@ -141,14 +141,14 @@ static void print_error_type_at(SourceSpan location, const char *message, PrintT unsigned space_to = col_location ? col_location : max_lines_for_display - 1; for (unsigned i = 0; i < space_to - 1; i++) { - switch (current[i]) + unsigned char c = (unsigned char)current[i]; + if (c == '\t') { - case '\t': - eprintf("\t"); - break; - default: - eprintf(" "); - break; + eprintf("\t"); + } + else + { + if (c < 128 || (c & 0xC0) == 0xC0) eprintf(" "); } } unsigned len = location.length;