aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-04-15 10:28:14 +0100
committergingerBill <bill@gingerbill.org>2024-04-15 10:28:14 +0100
commit2e29687ceeb004bfa820dd8c475786d2fed78a6d (patch)
treede4615edc02f4347fe7595b3aa6d93fba8175990
parentd510d5e49f0164753e8764dcb735bf2477c50a07 (diff)
Fix #3425
-rw-r--r--src/error.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/error.cpp b/src/error.cpp
index 8647f60b9..2e6641e3b 100644
--- a/src/error.cpp
+++ b/src/error.cpp
@@ -292,10 +292,11 @@ gb_internal isize show_error_on_line(TokenPos const &pos, TokenPos end, char con
if (line_len > MAX_LINE_LENGTH_PADDED) {
i32 left = MAX_TAB_WIDTH;
- if (offset > 0) {
- line_text += offset-left;
- line_len -= offset-left;
- offset = left+MAX_TAB_WIDTH/2;
+ i32 diff = gb_max(offset-left, 0);
+ if (diff > 0) {
+ line_text += diff;
+ line_len -= diff;
+ offset = left + ELLIPSIS_PADDING/2;
}
if (line_len > MAX_LINE_LENGTH_PADDED) {
line_len = MAX_LINE_LENGTH_PADDED;
@@ -304,7 +305,7 @@ gb_internal isize show_error_on_line(TokenPos const &pos, TokenPos end, char con
squiggle_extra = 1;
}
}
- if (offset > 0) {
+ if (diff > 0) {
error_out("... %.*s ...", cast(i32)line_len, line_text);
} else {
error_out("%.*s ...", cast(i32)line_len, line_text);