Skip to content

Commit

Permalink
update ast-check runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Feb 19, 2024
1 parent 97e6249 commit 0fb7651
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/features/diagnostics.zig
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ fn getDiagnosticsFromAstCheck(

var process = std.process.Child.init(&[_][]const u8{ zig_exe_path, "ast-check", "--color", "off" }, server.allocator);
process.stdin_behavior = .Pipe;
process.stdout_behavior = .Ignore;
process.stderr_behavior = .Pipe;

process.spawn() catch |err| {
Expand All @@ -410,15 +411,19 @@ fn getDiagnosticsFromAstCheck(

process.stdin = null;

const stderr_bytes = try process.stderr.?.reader().readAllAlloc(server.allocator, std.math.maxInt(usize));
const stderr_bytes = try process.stderr.?.readToEndAlloc(server.allocator, std.math.maxInt(usize));
errdefer server.allocator.free(stderr_bytes);

const term = process.wait() catch |err| {
log.warn("Failed to await zig ast-check process, error: {}", .{err});
server.allocator.free(stderr_bytes);
return;
};

if (term != .Exited) return;
if (term != .Exited) {
server.allocator.free(stderr_bytes);
return;
}
break :blk stderr_bytes;
};
defer server.allocator.free(stderr_bytes);
Expand Down

0 comments on commit 0fb7651

Please sign in to comment.