authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-22 17:17:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-22 17:17:32-07:00
log51701fb2da3562363d2c4966c5bf5d1b0ccad1a6
treef0dd3317e58873dc459d9a7a85e8646459055123
parent63aabbbba7872eb5178c32235bba260a13d6869a

stage2: omit printing source lines in compile errors

when configured to not use tty awareness

1 files changed, 12 insertions(+), 10 deletions(-)

src/Compilation.zig+12-10
......@@ -357,16 +357,18 @@ pub const AllErrors = struct {
357357 ttyconf.setColor(stderr, .Bold);
358358 try stderr.print(" {s}\n", .{src.msg});
359359 ttyconf.setColor(stderr, .Reset);
360 if (src.source_line) |line| {
361 for (line) |b| switch (b) {
362 '\t' => try stderr.writeByte(' '),
363 else => try stderr.writeByte(b),
364 };
365 try stderr.writeByte('\n');
366 try stderr.writeByteNTimes(' ', src.column);
367 ttyconf.setColor(stderr, .Green);
368 try stderr.writeAll("^\n");
369 ttyconf.setColor(stderr, .Reset);
360 if (ttyconf != .no_color) {
361 if (src.source_line) |line| {
362 for (line) |b| switch (b) {
363 '\t' => try stderr.writeByte(' '),
364 else => try stderr.writeByte(b),
365 };
366 try stderr.writeByte('\n');
367 try stderr.writeByteNTimes(' ', src.column);
368 ttyconf.setColor(stderr, .Green);
369 try stderr.writeAll("^\n");
370 ttyconf.setColor(stderr, .Reset);
371 }
370372 }
371373 for (src.notes) |note| {
372374 try note.renderToStdErrInner(ttyconf, stderr_file, "note:", .Cyan, indent);