Skip to content

Commit

Permalink
Merge pull request #55 from replete-repl/block-auto-eval
Browse files Browse the repository at this point in the history
It is possible to auto-eval on enter before engine ready
  • Loading branch information
mfikes authored May 19, 2019
2 parents 2e300c5 + 01fc57e commit ea22232
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Replete/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ class ViewController: NSViewController {
NSLog("Initializing...");
DispatchQueue.global(qos: .background).async {
self.ctx.initializeJavaScriptEnvironment()
DispatchQueue.main.async {
// mark ready
NSLog("Ready");
self.initialized = true;
}
self.initialized = true;
NSLog("Ready");
}

}
Expand All @@ -90,6 +87,9 @@ class ViewController: NSViewController {
// Automatically evaluate if enter happens to be pressed when
// cursor is positioned at the end of the text.
if (enterPressed && affectedCharRange.location == textView.string.count) {
while (!self.initialized) {
Thread.sleep(forTimeInterval: 0.1);
}
enterPressed = false
self.evaluate(textView)
return false;
Expand Down

0 comments on commit ea22232

Please sign in to comment.