macOS: normalize working directory paths with FilePath

This fixes for nuShell when opening Ghostty via Finder service and Shortcuts, also makes path parsing more robust in AppleScript.
This commit is contained in:
Lukas
2026-05-07 11:14:55 +02:00
parent 0deaac08ed
commit 607152ec6d

View File

@@ -1,6 +1,7 @@
import SwiftUI
import UserNotifications
import GhosttyKit
import System
extension Ghostty {
/// Render a terminal for the active app in the environment.
@@ -611,8 +612,20 @@ extension Ghostty {
/// Explicit font size to use in points
var fontSize: Float32?
private var normalizedWorkingDirectory: String?
/// Explicit working directory to set
var workingDirectory: String?
var workingDirectory: String? {
get { normalizedWorkingDirectory }
set {
guard let newValue else {
normalizedWorkingDirectory = nil
return
}
// We use FilePath to normalize separators by removing redundant intermediary separators
// and stripping any trailing separators.
normalizedWorkingDirectory = FilePath(newValue).string
}
}
/// Explicit command to set
var command: String?