From cc8bafb6b1b2cb12e57e699e2f08bebffd35a1b2 Mon Sep 17 00:00:00 2001 From: MauriceElliott Date: Mon, 30 Dec 2024 00:18:12 +0000 Subject: [PATCH] added conditional to edit.open so that when a config file exists in the app support directory on osx, it will prioritise opening that one over the one in the xdg config folder. --- src/config/edit.zig | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/config/edit.zig b/src/config/edit.zig index 692447594..2af792985 100644 --- a/src/config/edit.zig +++ b/src/config/edit.zig @@ -11,16 +11,23 @@ pub fn open(alloc_gpa: Allocator) !void { const xdg_config_path = try internal_os.xdg.config(alloc_gpa, .{ .subdir = "ghostty/config" }); if (comptime builtin.os.tag == .macos) macos: { - // On macOS, use the application support path if the XDG path doesn't exists. - if (std.fs.accessAbsolute(xdg_config_path, .{})) { - break :macos; + // On macOS, use the XDG path if the app support path doesn't exist. + const app_support_path = try internal_os.macos.appSupportDir(alloc_gpa, "config"); + if (std.fs.accessAbsolute(app_support_path, .{})) { + alloc_gpa.free(xdg_config_path); + break :config_path app_support_path; } else |err| switch (err) { error.BadPathName, error.FileNotFound => {}, else => break :macos, } - alloc_gpa.free(xdg_config_path); - break :config_path try internal_os.macos.appSupportDir(alloc_gpa, "config"); + if (std.fs.accessAbsolute(xdg_config_path, .{})) { + alloc_gpa.free(app_support_path); + break :macos; + } else |err| switch (err) { + error.BadPathName, error.FileNotFound => {}, + else => break :macos, + } } break :config_path xdg_config_path;