macos: opening filepaths should make proper file URLs

Fixes #8763
pull/8764/head
Mitchell Hashimoto 2025-09-18 13:28:23 -07:00
parent 834fe17abb
commit 4fa8b8f285
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
1 changed files with 9 additions and 4 deletions

View File

@ -624,10 +624,15 @@ extension Ghostty {
) -> Bool {
let action = Ghostty.Action.OpenURL(c: v)
// Convert the URL string to a URL object
guard let url = URL(string: action.url) else {
Ghostty.logger.warning("invalid URL for open URL action: \(action.url)")
return false
// If the URL doesn't have a valid scheme we assume its a file path. The URL
// initializer will gladly take invalid URLs (e.g. plain file paths) and turn
// them into schema-less URLs, but these won't open properly in text editors.
// See: https://github.com/ghostty-org/ghostty/issues/8763
let url: URL
if let candidate = URL(string: action.url), candidate.scheme != nil {
url = candidate
} else {
url = URL(filePath: action.url)
}
switch action.kind {