diff --git a/macos/Sources/Features/Services/ServiceProvider.swift b/macos/Sources/Features/Services/ServiceProvider.swift index 9bf46fcf9..fd3e8e9cc 100644 --- a/macos/Sources/Features/Services/ServiceProvider.swift +++ b/macos/Sources/Features/Services/ServiceProvider.swift @@ -42,10 +42,21 @@ class ServiceProvider: NSObject { // to their directories because that's the only thing we can open. let directoryURLs = Set( pathURLs.map { url -> URL in - url.hasDirectoryPath ? url : url.deletingLastPathComponent() + /// We check file system resources here because + /// NSURL doesn't append `/` when reading string contents from pasteboard + /// ``` + /// NSURL(pasteboardPropertyList: "/System/Library".propertyList(), ofType: .fileURL)?.hasDirectoryPath + /// ``` + let isDirectory = (try? url.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory ?? url.hasDirectoryPath + return isDirectory ? url : url.deletingLastPathComponent() } ) + guard !directoryURLs.isEmpty else { + error.pointee = Self.errorNoString + return + } + for url in directoryURLs { var config = Ghostty.SurfaceConfiguration() config.workingDirectory = url.path(percentEncoded: false)