Skip to content

Commit 40a31a3

Browse files
authored
Block auto-eval until engine ready (#137)
Fixes #136
1 parent b7a5141 commit 40a31a3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Replete/ReplViewController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ class ReplViewController: UIViewController, UITableViewDataSource, UITableViewDe
146146
NSLog("Initializing...");
147147
DispatchQueue.global(qos: .background).async {
148148
appDelegate.initializeJavaScriptEnvironment()
149+
self.initialized = true;
149150
DispatchQueue.main.async {
150151
// mark ready
151152
NSLog("Ready");
152-
self.initialized = true;
153153
let hasText = self.textView.hasText
154154
self.evalButton.isEnabled = hasText
155155
if (hasText) {
@@ -236,6 +236,9 @@ class ReplViewController: UIViewController, UITableViewDataSource, UITableViewDe
236236

237237
if (enterPressed && range.location == currentText!.count) {
238238
enterPressed = false
239+
while (!self.initialized) {
240+
Thread.sleep(forTimeInterval: 0.1);
241+
}
239242
sendAction()
240243
return false;
241244
}

0 commit comments

Comments
 (0)