Created
August 18, 2017 19:28
-
-
Save anonymous/f609e5eb1678cede4d94af0f6916f5b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: Private Properties | |
var redrawCaretWorkItem: DispatchWorkItem? | |
#if false // for Apple's bug | |
return super.readSelection(from: pboard, type: type) | |
#else | |
let wasPasted = super.readSelection(from: pboard, type: type) | |
if wasPasted { | |
if let workItem = self.redrawCaretWorkItem { | |
workItem.cancel() | |
} | |
self.redrawCaretWorkItem = DispatchWorkItem { | |
self.redrawCaretWorkItem = nil | |
self.isEditable = false; | |
DispatchQueue.main.async { | |
self.isEditable = true; | |
} | |
} | |
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: self.redrawCaretWorkItem!) | |
} | |
return wasPasted | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment