1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-25 06:06:21 +03:00

Refactor slightly

This commit is contained in:
Tae Won Ha 2017-08-08 09:53:30 +02:00
parent 0138899e40
commit d51522ed3a
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -16,22 +16,20 @@ extension NeoVimView {
}
override public func performDragOperation(_ sender: NSDraggingInfo) -> Bool {
if !isFile(sender: sender) {
return false;
}
let paths = sender
.draggingPasteboard()
.propertyList(forType: NSFilenamesPboardType)
as? [String]
let urls = paths?
.map { URL(fileURLWithPath: $0) }
?? []
self.open(urls: urls)
return true;
guard isFile(sender: sender) else {
return false
}
guard let paths = sender.draggingPasteboard().propertyList(forType: NSFilenamesPboardType) as? [String] else {
return false
}
self.open(urls: paths.map { URL(fileURLWithPath: $0) })
return true
}
}
fileprivate func isFile(sender: NSDraggingInfo?) -> Bool {
return (sender?.draggingPasteboard().types?.contains(String(kUTTypeFileURL))) ?? false
fileprivate func isFile(sender: NSDraggingInfo) -> Bool {
return (sender.draggingPasteboard().types?.contains(String(kUTTypeFileURL))) ?? false
}