diff options
| author | gingerBill <bill@gingerbill.org> | 2023-02-22 11:48:10 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-02-22 11:48:10 +0000 |
| commit | 090e30f07b10a79edf38736cc466a4f223167971 (patch) | |
| tree | ce4c3957789661066ef0acee1ca01a0ef1a79f84 /src/error.cpp | |
| parent | f5d507a9b9d20941bd86ba8559f710f21f0c8ccd (diff) | |
Make `-verbose-errors` the default; `-terse-errors` to disable it
Diffstat (limited to 'src/error.cpp')
| -rw-r--r-- | src/error.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/error.cpp b/src/error.cpp index 33157948f..cb2aa4836 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -121,7 +121,26 @@ gb_internal void end_error_block(void) { isize n = global_error_collector.error_buffer.count; if (n > 0) { u8 *text = global_error_collector.error_buffer.data; - if (show_error_line() && n >= 2 && !(text[n-2] == '\n' && text[n-1] == '\n')) { + + bool add_extra_newline = false; + + if (show_error_line()) { + if (n >= 2 && !(text[n-2] == '\n' && text[n-1] == '\n')) { + add_extra_newline = true; + } + } else { + isize newline_count = 0; + for (isize i = 0; i < n; i++) { + if (text[i] == '\n') { + newline_count += 1; + } + } + if (newline_count > 1) { + add_extra_newline = true; + } + } + + if (add_extra_newline) { // add an extra new line as padding when the error line is being shown error_line("\n"); } @@ -198,12 +217,12 @@ gb_internal bool show_error_on_line(TokenPos const &pos, TokenPos end) { // TODO(bill): This assumes ASCII enum { - MAX_LINE_LENGTH = 76, + MAX_LINE_LENGTH = 80, MAX_TAB_WIDTH = 8, - ELLIPSIS_PADDING = 8 + ELLIPSIS_PADDING = 8 // `... ...` }; - error_out("\n\t"); + error_out("\t"); if (line.len+MAX_TAB_WIDTH+ELLIPSIS_PADDING > MAX_LINE_LENGTH) { i32 const half_width = MAX_LINE_LENGTH/2; i32 left = cast(i32)(offset); @@ -244,7 +263,7 @@ gb_internal bool show_error_on_line(TokenPos const &pos, TokenPos end) { } } - error_out("\n\n"); + error_out("\n"); return true; } return false; |