aboutsummaryrefslogtreecommitdiff
path: root/src/error.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-02-22 22:57:11 +0000
committergingerBill <bill@gingerbill.org>2023-02-22 22:57:11 +0000
commit245a6697ef799ad60fc549e40369f4d36084620f (patch)
treea1566cab08861a2558772afc1f88b8964d9dc5ea /src/error.cpp
parent6226c2978d02bebd46adb7ceb68c010c71f9cc67 (diff)
Improve truncated verbose line error
Diffstat (limited to 'src/error.cpp')
-rw-r--r--src/error.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/error.cpp b/src/error.cpp
index a13c2bf5a..d20373be9 100644
--- a/src/error.cpp
+++ b/src/error.cpp
@@ -268,6 +268,8 @@ gb_internal bool show_error_on_line(TokenPos const &pos, TokenPos end) {
terminal_set_colours(TerminalStyle_Bold, TerminalColour_White);
+ isize squiggle_extra = 0;
+
if (line.len+MAX_TAB_WIDTH+ELLIPSIS_PADDING > MAX_LINE_LENGTH) {
i32 const half_width = MAX_LINE_LENGTH/2;
i32 left = cast(i32)(offset);
@@ -280,6 +282,7 @@ gb_internal bool show_error_on_line(TokenPos const &pos, TokenPos end) {
line = string_trim_whitespace(line);
+ squiggle_extra = ELLIPSIS_PADDING/2 + 1;
offset = left + ELLIPSIS_PADDING/2;
error_out("... %.*s ...", LIT(line));
@@ -302,10 +305,10 @@ gb_internal bool show_error_on_line(TokenPos const &pos, TokenPos end) {
}
} else if (end.line == pos.line && end.column > pos.column) {
i32 length = gb_min(end.offset - pos.offset, cast(i32)(line.len-offset));
- for (i32 i = 1; i < length-1; i++) {
+ for (i32 i = 1; i < length-1+squiggle_extra; i++) {
error_out("~");
}
- if (length > 1) {
+ if (length > 1 && squiggle_extra == 0) {
error_out("^");
}
}