aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/config/path.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/config/path.zig
parent90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff)
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/config/path.zig')
-rw-r--r--vendor/libghostty-vt/src/config/path.zig58
1 files changed, 34 insertions, 24 deletions
diff --git a/vendor/libghostty-vt/src/config/path.zig b/vendor/libghostty-vt/src/config/path.zig
index 793cf184..5fd88f33 100644
--- a/vendor/libghostty-vt/src/config/path.zig
+++ b/vendor/libghostty-vt/src/config/path.zig
@@ -7,6 +7,7 @@ const ArenaAllocator = std.heap.ArenaAllocator;
const cli = @import("../cli.zig");
const internal_os = @import("../os/main.zig");
const formatterpkg = @import("formatter.zig");
+const global = @import("../global.zig");
const log = std.log.scoped(.config);
@@ -163,7 +164,12 @@ pub const Path = union(enum) {
// Windows isn't supported yet
if (comptime builtin.os.tag == .windows) break :expand;
+ var environ_map = try global.environMap();
+ defer environ_map.deinit();
+
const expanded: []const u8 = internal_os.expandHome(
+ global.io(),
+ &environ_map,
path,
&buf,
) catch |err| {
@@ -195,32 +201,36 @@ pub const Path = union(enum) {
return;
}
- var dir = try std.fs.openDirAbsolute(base, .{});
- defer dir.close();
-
- const abs = dir.realpath(path, &buf) catch |err| abs: {
- if (err == error.FileNotFound) {
- // The file doesn't exist. Try to resolve the relative path
- // another way.
- const resolved = try std.fs.path.resolve(arena_alloc, &.{ base, path });
- defer arena_alloc.free(resolved);
- @memcpy(buf[0..resolved.len], resolved);
- break :abs buf[0..resolved.len];
- }
+ var dir = try std.Io.Dir.openDirAbsolute(global.io(), base, .{});
+ defer dir.close(global.io());
- try diags.append(arena_alloc, .{
- .message = try std.fmt.allocPrintSentinel(
- arena_alloc,
- "error resolving file path {s}: {}",
- .{ path, err },
- 0,
- ),
- });
+ const abs = abs: {
+ const abs_len = dir.realPathFile(global.io(), path, &buf) catch |err| {
+ if (err == error.FileNotFound) {
+ // The file doesn't exist. Try to resolve the relative path
+ // another way.
+ const resolved = try std.fs.path.resolve(arena_alloc, &.{ base, path });
+ defer arena_alloc.free(resolved);
+ @memcpy(buf[0..resolved.len], resolved);
+ break :abs buf[0..resolved.len];
+ }
- // Blank this path so that we don't attempt to resolve it again
- self.* = .{ .required = "" };
+ try diags.append(arena_alloc, .{
+ .message = try std.fmt.allocPrintSentinel(
+ arena_alloc,
+ "error resolving file path {s}: {}",
+ .{ path, err },
+ 0,
+ ),
+ });
- return;
+ // Blank this path so that we don't attempt to resolve it again
+ self.* = .{ .required = "" };
+
+ return;
+ };
+
+ break :abs buf[0..abs_len];
};
log.debug(
@@ -357,7 +367,7 @@ pub const Path = union(enum) {
/// be automatically expanded relative to the path of the config file (or the home
/// directory).
pub const RepeatablePath = struct {
- value: std.ArrayListUnmanaged(Path) = .{},
+ value: std.ArrayList(Path) = .empty,
pub fn parseCLI(self: *RepeatablePath, alloc: Allocator, input: ?[]const u8) ParseError!void {
const item = try Path.parse(alloc, input) orelse {