diff options
| author | Mitchell Hashimoto <m@mitchellh.com> | 2024-12-29 19:49:31 -0800 |
|---|---|---|
| committer | Mitchell Hashimoto <m@mitchellh.com> | 2024-12-30 08:43:59 -0800 |
| commit | adcaff7137ef1fedf5f094126032ce7de34d73e1 (patch) | |
| tree | 392e081e21bbfda9db6fa5371ef2c9ecb0151309 /src/Surface.zig | |
| parent | 3059d9036b233d672e6dc7cdfb91c822978cc1ef (diff) | |
config: edit opens AppSupport over XDG on macOS, prefers non-empty paths
Fixes #3953
Fixes #3284
This fixes two issues. In fixing one issue, the other became apparent so
I fixed both in this one commit.
The first issue is that on macOS, the `open` command should take the
`-t` flag to open text files in a text editor. To do this, the `os.open`
function now takes a type hint that is used to better do the right
thing.
Second, the order of the paths that we attempt to open when editing a
config on macOS is wrong. Our priority when loading configs is well documented:
https://ghostty.org/docs/config#macos-specific-path-(macos-only). But
open_config does the opposite. This makes it too easy for people to have
configs that are being overridden without them realizing it.
This commit changes the order of the paths to match the documented
order. If neither path exists, we prefer AppSupport.
Diffstat (limited to 'src/Surface.zig')
| -rw-r--r-- | src/Surface.zig | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Surface.zig b/src/Surface.zig index 053dec3fd..13e986919 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3195,7 +3195,7 @@ fn processLinks(self: *Surface, pos: apprt.CursorPos) !bool { .trim = false, }); defer self.alloc.free(str); - try internal_os.open(self.alloc, str); + try internal_os.open(self.alloc, .unknown, str); }, ._open_osc8 => { @@ -3203,7 +3203,7 @@ fn processLinks(self: *Surface, pos: apprt.CursorPos) !bool { log.warn("failed to get URI for OSC8 hyperlink", .{}); return false; }; - try internal_os.open(self.alloc, uri); + try internal_os.open(self.alloc, .unknown, uri); }, } @@ -4303,7 +4303,7 @@ fn writeScreenFile( const path = try tmp_dir.dir.realpath(filename, &path_buf); switch (write_action) { - .open => try internal_os.open(self.alloc, path), + .open => try internal_os.open(self.alloc, .text, path), .paste => self.io.queueMessage(try termio.Message.writeReq( self.alloc, path, |
