authorgravatar for yujiri@disroot.orgyujiri8 <yujiri@disroot.org> 2022-10-20 10:57:57+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-10-20 13:57:57+03:00
loga99d465f624d9cdd82d270e03dd931c0539df8d7
treeb4a9fdb2ffe99cd786fb5a9770e51830db8609b3
parenta4eb221b9ef7dab8fa1c6cc07c7891e25d98d2b6
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Fix #12091: Error message with TERM=dumb is missing info


2 files changed, 18 insertions(+), 19 deletions(-)

src/Compilation.zig+17-19
......@@ -429,25 +429,23 @@ pub const AllErrors = struct {
429429 try stderr.print(" ({d} times)\n", .{src.count});
430430 }
431431 ttyconf.setColor(stderr, .Reset);
432 if (ttyconf != .no_color) {
433 if (src.source_line) |line| {
434 for (line) |b| switch (b) {
435 '\t' => try stderr.writeByte(' '),
436 else => try stderr.writeByte(b),
437 };
438 try stderr.writeByte('\n');
439 // TODO basic unicode code point monospace width
440 const before_caret = src.span.main - src.span.start;
441 // -1 since span.main includes the caret
442 const after_caret = src.span.end - src.span.main -| 1;
443 try stderr.writeByteNTimes(' ', src.column - before_caret);
444 ttyconf.setColor(stderr, .Green);
445 try stderr.writeByteNTimes('~', before_caret);
446 try stderr.writeByte('^');
447 try stderr.writeByteNTimes('~', after_caret);
448 try stderr.writeByte('\n');
449 ttyconf.setColor(stderr, .Reset);
450 }
432 if (src.source_line) |line| {
433 for (line) |b| switch (b) {
434 '\t' => try stderr.writeByte(' '),
435 else => try stderr.writeByte(b),
436 };
437 try stderr.writeByte('\n');
438 // TODO basic unicode code point monospace width
439 const before_caret = src.span.main - src.span.start;
440 // -1 since span.main includes the caret
441 const after_caret = src.span.end - src.span.main -| 1;
442 try stderr.writeByteNTimes(' ', src.column - before_caret);
443 ttyconf.setColor(stderr, .Green);
444 try stderr.writeByteNTimes('~', before_caret);
445 try stderr.writeByte('^');
446 try stderr.writeByteNTimes('~', after_caret);
447 try stderr.writeByte('\n');
448 ttyconf.setColor(stderr, .Reset);
451449 }
452450 for (src.notes) |note| {
453451 try note.renderToWriter(ttyconf, stderr, "note", .Cyan, indent);
src/test.zig+1
......@@ -1662,6 +1662,7 @@ pub const TestContext = struct {
16621662 var msg: Compilation.AllErrors.Message = actual_error;
16631663 msg.src.src_path = case_msg.src.src_path;
16641664 msg.src.notes = &.{};
1665 msg.src.source_line = null;
16651666 var fib = std.io.fixedBufferStream(&buf);
16661667 try msg.renderToWriter(.no_color, fib.writer(), "error", .Red, 0);
16671668 var it = std.mem.split(u8, fib.getWritten(), "error: ");