mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-21 14:55:20 +00:00
macOS: switch to using URL instead of String
This commit is contained in:
@@ -36,30 +36,27 @@ class ServiceProvider: NSObject {
|
||||
error.pointee = Self.errorNoString
|
||||
return
|
||||
}
|
||||
let filePaths = objs.map { $0.path }.compactMap { $0 }
|
||||
let urlObjects = objs.map { $0 as URL }
|
||||
|
||||
openTerminal(filePaths, target: target)
|
||||
openTerminal(urlObjects, target: target)
|
||||
}
|
||||
|
||||
private func openTerminal(_ paths: [String], target: OpenTarget) {
|
||||
private func openTerminal(_ urls: [URL], target: OpenTarget) {
|
||||
guard let delegateRaw = NSApp.delegate else { return }
|
||||
guard let delegate = delegateRaw as? AppDelegate else { return }
|
||||
let terminalManager = delegate.terminalManager
|
||||
|
||||
for path in paths {
|
||||
// We only open in directories.
|
||||
var isDirectory = ObjCBool(true)
|
||||
guard FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory) else { continue }
|
||||
|
||||
var workingDirectory = path
|
||||
if !isDirectory.boolValue {
|
||||
workingDirectory = (path as NSString).deletingLastPathComponent
|
||||
guard FileManager.default.fileExists(atPath: workingDirectory, isDirectory: &isDirectory), isDirectory.boolValue else { continue }
|
||||
let uniqueCwds: Set<URL> = Set(
|
||||
urls.map { url -> URL in
|
||||
// We only open in directories.
|
||||
url.hasDirectoryPath ? url : url.deletingLastPathComponent()
|
||||
}
|
||||
)
|
||||
|
||||
for cwd in uniqueCwds {
|
||||
// Build our config
|
||||
var config = Ghostty.SurfaceConfiguration()
|
||||
config.workingDirectory = workingDirectory
|
||||
config.workingDirectory = cwd.path(percentEncoded: false)
|
||||
|
||||
switch (target) {
|
||||
case .window:
|
||||
|
||||
Reference in New Issue
Block a user