macOS: expand tilde in file paths before opening#10863
Merged
mitchellh merged 1 commit intoghostty-org:mainfrom Feb 21, 2026
Merged
macOS: expand tilde in file paths before opening#10863mitchellh merged 1 commit intoghostty-org:mainfrom
mitchellh merged 1 commit intoghostty-org:mainfrom
Conversation
Contributor
|
Hi @AlexFeijoo44, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/ghostty-org/ghostty/blob/main/CONTRIBUTING.md for more details. |
Contributor
|
!vouch |
Merged
ghostty-vouch bot
added a commit
that referenced
this pull request
Feb 20, 2026
Triggered by [comment](#10863 (comment)) from @mitchellh. Vouch: @AlexFeijoo44 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
mitchellh
approved these changes
Feb 20, 2026
Contributor
mitchellh
left a comment
There was a problem hiding this comment.
Thanks, this simple change looks right to me.
jparise
reviewed
Feb 20, 2026
`URL(filePath:)` treats `~` as a literal directory name, so cmd-clicking a path like `~/Documents/file.txt` would fail to open because the resulting file URL doesn't point to a real file. Use `NSString.expandingTildeInPath` to resolve `~` to the user's home directory before constructing the file URL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ccc43b5 to
b65261e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cmd-clicking a file path containing
~(e.g.~/Documents/file.txt) fails to open the file on macOS becauseURL(filePath:)treats~as a literal directory name rather than the user's home directory.This uses
NSString.expandingTildeInPathto resolve~before constructing the file URL.Root Cause
In
openURL(), when the URL string has no scheme it falls through to:Swift's
URL(filePath:)does not perform tilde expansion. A path like~/Documents/file.txtproduces a URL pointing to a non-existent file, andNSWorkspace.opensilently fails.Fix
Reproduction
~prefixesWith this fix, the path resolves correctly and opens in the default editor.