about summary refs log tree commit diff stats
path: root/edit
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-22 23:30:03 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-22 23:30:03 -0800
commite0d69d3b3326081dda661d714cef97a13dabb7c8 (patch)
tree95d116f4bf10f8a5f53024851c617553fd46c862 /edit
parent56d26afb1ac967339217d5cf3eda9af85e9a278d (diff)
downloadmu-e0d69d3b3326081dda661d714cef97a13dabb7c8.tar.gz
2593 - bugfix: editing a sandbox resets scroll
Diffstat (limited to 'edit')
-rw-r--r--edit/006-sandbox-edit.mu54
1 files changed, 54 insertions, 0 deletions
diff --git a/edit/006-sandbox-edit.mu b/edit/006-sandbox-edit.mu
index 496882d6..db1ee324 100644
--- a/edit/006-sandbox-edit.mu
+++ b/edit/006-sandbox-edit.mu
@@ -81,6 +81,10 @@ after <global-touch> [
     sandbox:address:shared:sandbox-data <- extract-sandbox env, click-row
     text:address:shared:array:character <- get *sandbox, data:offset
     current-sandbox <- insert-text current-sandbox, text
+    first-sandbox-to-render:address:address:shared:sandbox-data <- get-address *env, first-sandbox-to-render:offset
+    *first-sandbox-to-render <- copy 0
+    first-sandbox-index:address:number <- get-address *env, first-sandbox-index:offset
+    *first-sandbox-index <- copy 0
     hide-screen screen
     screen <- render-sandbox-side screen, env
     screen <- update-cursor screen, recipes, current-sandbox, *sandbox-in-focus?, env
@@ -166,3 +170,53 @@ scenario sandbox-with-print-can-be-edited [
     .                                                  ┊                                                 .
   ]
 ]
+
+scenario editing-sandbox-after-scrolling-resets-scroll [
+  trace-until 100/app  # trace too long
+  assume-screen 30/width, 10/height
+  # initialize environment
+  1:address:shared:array:character <- new []
+  2:address:shared:array:character <- new []
+  3:address:shared:programming-environment-data <- new-programming-environment screen:address:shared:screen, 1:address:shared:array:character, 2:address:shared:array:character
+  render-all screen, 3:address:shared:programming-environment-data
+  # create 2 sandboxes and scroll to second
+  assume-console [
+    press ctrl-n
+    type [add 2, 2]
+    press F4
+    type [add 1, 1]
+    press F4
+    press down-arrow
+    press down-arrow
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data
+  ]
+  screen-should-contain [
+    .                              .
+    .               ┊━━━━━━━━━━━━━━.
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1            x.
+    .               ┊add 2, 2      .
+    .               ┊4             .
+    .               ┊━━━━━━━━━━━━━━.
+    .               ┊              .
+  ]
+  # edit the second sandbox
+  assume-console [
+    left-click 2, 20
+  ]
+  run [
+    event-loop screen:address:shared:screen, console:address:shared:console, 3:address:shared:programming-environment-data
+  ]
+  # second sandbox shows in editor; scroll resets to display first sandbox
+  screen-should-contain [
+    .                              .
+    .               ┊add 2, 2      .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━.
+    .               ┊0            x.
+    .               ┊add 1, 1      .
+    .               ┊2             .
+    .               ┊━━━━━━━━━━━━━━.
+    .               ┊              .
+  ]
+]