From d51522ed3a0aeba08dd4ab0db70a4716c7548524 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Tue, 8 Aug 2017 09:53:30 +0200 Subject: [PATCH] Refactor slightly --- SwiftNeoVim/NeoVimView+Dragging.swift | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/SwiftNeoVim/NeoVimView+Dragging.swift b/SwiftNeoVim/NeoVimView+Dragging.swift index a2f697f0..6c15d7fb 100644 --- a/SwiftNeoVim/NeoVimView+Dragging.swift +++ b/SwiftNeoVim/NeoVimView+Dragging.swift @@ -16,22 +16,20 @@ extension NeoVimView { } override public func performDragOperation(_ sender: NSDraggingInfo) -> Bool { - if !isFile(sender: sender) { - return false; + guard isFile(sender: sender) else { + 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 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 }