Skip to content

Commit

Permalink
refactored DispatchTime related code
Browse files Browse the repository at this point in the history
  • Loading branch information
dev4dev committed Oct 21, 2016
1 parent 8124df3 commit d8c7b09
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions MarvinPlugIn/Source/MarvinPlugIn/MarvinPlugin.swift
Expand Up @@ -110,7 +110,7 @@ class MarvinPlugin: NSObject {
} else {
perform(keyboardEvent: 126)

let delayTime = DispatchTime.now() + Double(Int64(0.025 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
let delayTime = DispatchTime.now() + 0.025
DispatchQueue.main.asyncAfter(deadline: delayTime) { [unowned self] in
let currentRange = self.xcode.selectedRange

Expand All @@ -130,7 +130,7 @@ class MarvinPlugin: NSObject {

perform(keyboardEvent: 125)

let delayTime = DispatchTime.now() + Double(Int64(0.025 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
let delayTime = DispatchTime.now() + 0.025
DispatchQueue.main.asyncAfter(deadline: delayTime) { [unowned self] in
self.selectWordAction()
}
Expand Down
4 changes: 2 additions & 2 deletions MarvinPlugIn/Source/MarvinPlugIn/XcodeManager.swift
Expand Up @@ -209,7 +209,7 @@ class XcodeManager: NSObject {
func insertText(_ string: String) {
self.textView?.insertText(string)

let delayTime = DispatchTime.now() + Double(Int64(0.025 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
let delayTime = DispatchTime.now() + 0.025
DispatchQueue.main.asyncAfter(deadline: delayTime) {
NotificationCenter.default.post(name: Notification.Name(rawValue: "Add change mark"), object: string)
}
Expand All @@ -226,7 +226,7 @@ class XcodeManager: NSObject {

textStorage?.replaceCharacters(in: range, with: string, withUndoManager: document?.undoManager)

let delayTime = DispatchTime.now() + Double(Int64(0.025 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
let delayTime = DispatchTime.now() + 0.025
DispatchQueue.main.asyncAfter(deadline: delayTime) {
NotificationCenter.default.post(name: Notification.Name(rawValue: "Add change mark"), object: string)
}
Expand Down
Expand Up @@ -29,7 +29,7 @@ extension NSDocument {
NotificationCenter.default.post(name: Notification.Name(rawValue: "Save properly"), object: nil)
}

let delayTime = DispatchTime.now() + Double(Int64(0.25 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
let delayTime = DispatchTime.now() + 0.25
DispatchQueue.main.asyncAfter(deadline: delayTime) {
self.zen_saveDocumentWithDelegate(delegate, didSaveSelector: didSaveSelector, contextInfo: contextInfo)
}
Expand Down

0 comments on commit d8c7b09

Please sign in to comment.