about summary refs log tree commit diff stats
path: root/sandbox
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-05-05 17:02:46 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-05-05 17:02:46 -0700
commit5d5116e3343b5f6efa289e35e1c29b761db12068 (patch)
tree9c6c44aaea2731132ab51d6e0df0d7e3be589c13 /sandbox
parenta2f5a5d3fd13fba97571c39951304a44e7f84e5d (diff)
downloadmu-5d5116e3343b5f6efa289e35e1c29b761db12068.tar.gz
2928 - fix sandbox restore in edit/ and sandbox/
This had been broken ever since 2854, because we can't write tests for
restore-snapshots at the moment.
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/005-sandbox.mu10
1 files changed, 7 insertions, 3 deletions
diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu
index c946fba2..227a1ee0 100644
--- a/sandbox/005-sandbox.mu
+++ b/sandbox/005-sandbox.mu
@@ -317,6 +317,7 @@ def! restore-sandboxes env:address:programming-environment-data -> env:address:p
     filename:address:array:character <- to-text idx
     contents:address:array:character <- restore filename
     break-unless contents  # stop at first error; assuming file didn't exist
+                           # todo: handle empty sandbox
     # create new sandbox for file
     curr <- new sandbox-data:type
     *curr <- put *curr, data:offset, contents
@@ -328,15 +329,18 @@ def! restore-sandboxes env:address:programming-environment-data -> env:address:p
       <end-restore-sandbox>
     }
     +continue
-    idx <- add idx, 1
     {
-      break-unless prev
+      break-if idx
+      *env <- put *env, sandbox:offset, curr
+    }
+    {
+      break-unless idx
       *prev <- put *prev, next-sandbox:offset, curr
     }
+    idx <- add idx, 1
     prev <- copy curr
     loop
   }
-  *env <- put *env, sandbox:offset, curr
   # update sandbox count
   *env <- put *env, number-of-sandboxes:offset, idx
 ]