From 2b480457316b3b21739d3ed26b301e456f5856c7 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Sat, 9 May 2026 14:37:43 -0400 Subject: [PATCH] macos: simplify workingDirectory setter This is a minor improvement to the computed property's `set` logic: we can just use `.map {}` to unify the two optional paths. --- .../Ghostty/Surface View/SurfaceView.swift | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView.swift b/macos/Sources/Ghostty/Surface View/SurfaceView.swift index a17d8d704..4b90a3016 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView.swift @@ -612,20 +612,13 @@ extension Ghostty { /// Explicit font size to use in points var fontSize: Float32? - private var normalizedWorkingDirectory: String? - /// Explicit working directory to set + /// Explicit working directory. This is normalized on assignment to + /// remove any redundant and trailing path separators. 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 - } + set { normalizedWorkingDirectory = newValue.map { FilePath($0).string } } } + private var normalizedWorkingDirectory: String? /// Explicit command to set var command: String?