mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-26 07:13:24 +03:00
GH-458 Fix open files by drag-n-dropping on VimR window
This commit is contained in:
parent
31c49215bc
commit
efbc9af8da
@ -7,11 +7,15 @@ import Cocoa
|
|||||||
|
|
||||||
extension NvimView {
|
extension NvimView {
|
||||||
|
|
||||||
override public func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
|
override public func draggingEntered(
|
||||||
|
_ sender: NSDraggingInfo
|
||||||
|
) -> NSDragOperation {
|
||||||
return isFile(sender: sender) ? .copy : NSDragOperation()
|
return isFile(sender: sender) ? .copy : NSDragOperation()
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func draggingUpdated(_ sender: NSDraggingInfo) -> NSDragOperation {
|
override public func draggingUpdated(
|
||||||
|
_ sender: NSDraggingInfo
|
||||||
|
) -> NSDragOperation {
|
||||||
return isFile(sender: sender) ? .copy : NSDragOperation()
|
return isFile(sender: sender) ? .copy : NSDragOperation()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,16 +24,15 @@ extension NvimView {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let paths = sender.draggingPasteboard.propertyList(
|
guard let urls = sender.draggingPasteboard
|
||||||
forType: NSPasteboard.PasteboardType(String(kUTTypeFileURL))
|
.readObjects(forClasses: [NSURL.self]) as? [URL] else { return false }
|
||||||
) as? [String] else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
self.open(urls: paths.map { URL(fileURLWithPath: $0) })
|
self.open(urls: urls)
|
||||||
.subscribeOn(self.scheduler)
|
.subscribeOn(self.scheduler)
|
||||||
.subscribe(onError: { error in
|
.subscribe(onError: { error in
|
||||||
self.eventsSubject.onNext(.apiError(msg: "\(paths) could not be opened.", cause: error))
|
self.eventsSubject.onNext(
|
||||||
|
.apiError(msg: "\(urls) could not be opened.", cause: error)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.disposed(by: self.disposeBag)
|
.disposed(by: self.disposeBag)
|
||||||
|
|
||||||
@ -38,5 +41,7 @@ extension NvimView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func isFile(sender: NSDraggingInfo) -> Bool {
|
private func isFile(sender: NSDraggingInfo) -> Bool {
|
||||||
return (sender.draggingPasteboard.types?.contains(NSPasteboard.PasteboardType(String(kUTTypeFileURL)))) ?? false
|
return (sender.draggingPasteboard.types?.contains(
|
||||||
|
NSPasteboard.PasteboardType(String(kUTTypeFileURL))
|
||||||
|
)) ?? false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user