Skip to content

Commit e3e9b51

Browse files
authored
macos: simplify workingDirectory setter (ghostty-org#12639)
This is a minor improvement to the computed property's `set` logic: we can just use `.map {}` to unify the two optional paths.
2 parents a330ee9 + 2b48045 commit e3e9b51

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

macos/Sources/Ghostty/Surface View/SurfaceView.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -612,20 +612,13 @@ extension Ghostty {
612612
/// Explicit font size to use in points
613613
var fontSize: Float32?
614614

615-
private var normalizedWorkingDirectory: String?
616-
/// Explicit working directory to set
615+
/// Explicit working directory. This is normalized on assignment to
616+
/// remove any redundant and trailing path separators.
617617
var workingDirectory: String? {
618618
get { normalizedWorkingDirectory }
619-
set {
620-
guard let newValue else {
621-
normalizedWorkingDirectory = nil
622-
return
623-
}
624-
// We use FilePath to normalize separators by removing redundant intermediary separators
625-
// and stripping any trailing separators.
626-
normalizedWorkingDirectory = FilePath(newValue).string
627-
}
619+
set { normalizedWorkingDirectory = newValue.map { FilePath($0).string } }
628620
}
621+
private var normalizedWorkingDirectory: String?
629622

630623
/// Explicit command to set
631624
var command: String?

0 commit comments

Comments
 (0)