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