about summary refs log tree commit diff stats
path: root/edit.mu
diff options
context:
space:
mode:
Diffstat (limited to 'edit.mu')
-rw-r--r--edit.mu42
1 files changed, 25 insertions, 17 deletions
diff --git a/edit.mu b/edit.mu
index e4a7f340..fedd9f9f 100644
--- a/edit.mu
+++ b/edit.mu
@@ -2774,7 +2774,6 @@ recipe run-sandboxes [
   local-scope
   env:address:programming-environment-data <- next-ingredient
   recipes:address:editor-data <- get *env, recipes:offset
-  current-sandbox:address:editor-data <- get *env, current-sandbox:offset
   # copy code from recipe editor, persist, load into mu, save any warnings
   in:address:array:character <- editor-contents recipes
   save [recipes.mu], in
@@ -2783,6 +2782,7 @@ recipe run-sandboxes [
   # if recipe editor has errors, stop
   reply-if *recipe-warnings
   # check contents of right editor (sandbox)
+  current-sandbox:address:editor-data <- get *env, current-sandbox:offset
   {
     sandbox-contents:address:array:character <- editor-contents current-sandbox
     break-unless sandbox-contents
@@ -2801,6 +2801,26 @@ recipe run-sandboxes [
     *init <- push-duplex 167/§, 0/tail
   }
   # save all sandboxes before running, just in case we die when running
+  save-sandboxes env
+  # run all sandboxes
+  curr:address:sandbox-data <- get *env, sandbox:offset
+  {
+    break-unless curr
+    data <- get-address *curr, data:offset
+    response:address:address:array:character <- get-address *curr, response:offset
+    warnings:address:address:array:character <- get-address *curr, warnings:offset
+    fake-screen:address:address:screen <- get-address *curr, screen:offset
+    *response, *warnings, *fake-screen <- run-interactive *data
+#?     $print *warnings, [ ], **warnings, 10/newline
+    curr <- get *curr, next-sandbox:offset
+    loop
+  }
+]
+
+recipe save-sandboxes [
+  local-scope
+  env:address:programming-environment-data <- next-ingredient
+  current-sandbox:address:editor-data <- get *env, current-sandbox:offset
   # first clear previous versions, in case we deleted some sandbox
   $system [rm lesson/[0-9]* >/dev/null 2>/dev/null]  # some shells can't handle '>&'
   curr:address:sandbox-data <- get *env, sandbox:offset
@@ -2808,9 +2828,9 @@ recipe run-sandboxes [
   idx:number <- copy 0
   {
     break-unless curr
-    data <- get-address *curr, data:offset
+    data:address:array:character <- get *curr, data:offset
     filename:address:array:character <- integer-to-decimal-string idx
-    save filename, *data
+    save filename, data
     {
       expected-response:address:array:character <- get *curr, expected-response:offset
       break-unless expected-response
@@ -2821,19 +2841,6 @@ recipe run-sandboxes [
     curr <- get *curr, next-sandbox:offset
     loop
   }
-  # run all sandboxes
-  curr <- get *env, sandbox:offset
-  {
-    break-unless curr
-    data <- get-address *curr, data:offset
-    response:address:address:array:character <- get-address *curr, response:offset
-    warnings:address:address:array:character <- get-address *curr, warnings:offset
-    fake-screen:address:address:screen <- get-address *curr, screen:offset
-    *response, *warnings, *fake-screen <- run-interactive *data
-#?     $print *warnings, [ ], **warnings, 10/newline
-    curr <- get *curr, next-sandbox:offset
-    loop
-  }
 ]
 
 recipe render-sandbox-side [
@@ -3529,8 +3536,9 @@ after +global-touch [
     # identify the sandbox whose output is being clicked on
     sandbox:address:sandbox-data <- find-click-in-sandbox-output env, click-row
     break-unless sandbox
-    # toggle its expected-response
+    # toggle its expected-response, and save session
     sandbox <- toggle-expected-response sandbox
+    save-sandboxes env
     screen <- render-sandbox-side screen, env, 1/clear
     # no change in cursor
     show-screen screen