aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/cli/crash_report.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-10 21:51:57 +0300
committerGitHub <noreply@github.com>2026-09-10 21:51:57 +0300
commit425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch)
treee52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/src/cli/crash_report.zig
parent90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff)
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/cli/crash_report.zig')
-rw-r--r--vendor/libghostty-vt/src/cli/crash_report.zig25
1 files changed, 15 insertions, 10 deletions
diff --git a/vendor/libghostty-vt/src/cli/crash_report.zig b/vendor/libghostty-vt/src/cli/crash_report.zig
index f0940fda..e189ddae 100644
--- a/vendor/libghostty-vt/src/cli/crash_report.zig
+++ b/vendor/libghostty-vt/src/cli/crash_report.zig
@@ -4,6 +4,7 @@ const args = @import("args.zig");
const Action = @import("ghostty.zig").Action;
const Config = @import("../config.zig").Config;
const crash = @import("../crash/main.zig");
+const global = @import("../global.zig");
pub const Options = struct {
pub fn deinit(self: Options) void {
@@ -33,32 +34,36 @@ pub fn run(alloc_gpa: Allocator) !u8 {
defer opts.deinit();
{
- var iter = try args.argsIterator(alloc_gpa);
+ var iter = try args.argsIterator(alloc_gpa, global.args());
defer iter.deinit();
try args.parse(Options, alloc_gpa, &opts, &iter);
}
var buffer: [1024]u8 = undefined;
- var stdout_file: std.fs.File = .stdout();
- var stdout_writer = stdout_file.writer(&buffer);
+ var stdout_file: std.Io.File = .stdout();
+ var stdout_writer = stdout_file.writer(global.io(), &buffer);
const stdout = &stdout_writer.interface;
- const result = runInner(alloc, &stdout_file, stdout);
+ var environ_map = try global.environMap();
+ defer environ_map.deinit();
+ const result = runInner(global.io(), alloc, &environ_map, &stdout_file, stdout);
stdout.flush() catch {};
return result;
}
fn runInner(
+ io: std.Io,
alloc: Allocator,
- stdout_file: *std.fs.File,
+ environ_map: *const std.process.Environ.Map,
+ stdout_file: *std.Io.File,
stdout: *std.Io.Writer,
) !u8 {
- const crash_dir = try crash.defaultDir(alloc);
+ const crash_dir = try crash.defaultDir(io, alloc, environ_map);
var reports: std.ArrayList(crash.Report) = .empty;
errdefer reports.deinit(alloc);
- var it = try crash_dir.iterator();
- while (try it.next()) |report| try reports.append(alloc, .{
+ var it = try crash_dir.iterator(io);
+ while (try it.next(io)) |report| try reports.append(alloc, .{
.name = try alloc.dupe(u8, report.name),
.mtime = report.mtime,
});
@@ -66,7 +71,7 @@ fn runInner(
// If we have no reports, then we're done. If we have a tty then we
// print a message, otherwise we do nothing.
if (reports.items.len == 0) {
- if (std.posix.isatty(stdout_file.handle)) {
+ if (try stdout_file.isTty(global.io())) {
try stdout.writeAll("No crash reports! 👻\n");
}
return 0;
@@ -76,7 +81,7 @@ fn runInner(
for (reports.items) |report| {
var buf: [128]u8 = undefined;
- const now = std.time.nanoTimestamp();
+ const now = std.Io.Timestamp.now(global.io(), .real).toNanoseconds();
const diff = now - report.mtime;
const since = if (diff <= 0) "now" else s: {
const d = Config.Duration{ .duration = @intCast(diff) };