about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-27 00:31:15 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-27 00:33:15 -0700
commit5efd2b6b56bdb8d365ff24aa212b405e9ff37f2e (patch)
treeda22e0fcdbc63542caf2d9199469dd94ab759dde
parenta4f5644776543e1e1211028d18f67b9164255155 (diff)
downloadmu-5efd2b6b56bdb8d365ff24aa212b405e9ff37f2e.tar.gz
2085 - undo/redo now working for simple typing
Not yet useable, because we never ever stop coalescing operations. That
will happen when we introduce a second type of operation.
-rw-r--r--065duplex_list.mu7
-rw-r--r--edit.mu50
2 files changed, 55 insertions, 2 deletions
diff --git a/065duplex_list.mu b/065duplex_list.mu
index 3310400d..65cb9592 100644
--- a/065duplex_list.mu
+++ b/065duplex_list.mu
@@ -411,8 +411,11 @@ recipe insert-duplex-range [
   next:address:duplex-list <- next-duplex in
   dest:address:address:duplex-list <- get-address *end, next:offset
   *dest <- copy next
-  dest <- get-address *next, prev:offset
-  *dest <- copy end
+  {
+    break-unless next
+    dest <- get-address *next, prev:offset
+    *dest <- copy end
+  }
   dest <- get-address *in, next:offset
   *dest <- copy start
   dest <- get-address *start, prev:offset
diff --git a/edit.mu b/edit.mu
index 3e643fa9..c33fa4e8 100644
--- a/edit.mu
+++ b/edit.mu
@@ -6782,6 +6782,56 @@ scenario editor-redo-typing [
   ]
 ]
 
+scenario editor-redo-typing-empty [
+  # create an editor, type something, undo
+  assume-screen 10/width, 5/height
+  1:address:array:character <- new []
+  2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right
+  editor-render screen, 2:address:editor-data
+  assume-console [
+    type [012]
+    type [z]  # ctrl-z
+  ]
+  3:event/ctrl-z <- merge 0/text, 26/ctrl-z, 0/dummy, 0/dummy
+  replace-in-console 122/z, 3:event/ctrl-z
+  editor-event-loop screen:address, console:address, 2:address:editor-data
+  screen-should-contain [
+    .          .
+    .          .
+    .┈┈┈┈┈┈┈┈┈┈.
+    .          .
+  ]
+  # redo
+  assume-console [
+    type [y]  # ctrl-y
+  ]
+  4:event/ctrl-y <- merge 0/text, 25/ctrl-y, 0/dummy, 0/dummy
+  replace-in-console 121/y, 4:event/ctrl-y
+  run [
+    editor-event-loop screen:address, console:address, 2:address:editor-data
+  ]
+  # all characters must be back
+  screen-should-contain [
+    .          .
+    .012       .
+    .┈┈┈┈┈┈┈┈┈┈.
+    .          .
+  ]
+  # cursor should be in the right place
+  assume-console [
+    type [3]
+  ]
+  run [
+    editor-event-loop screen:address, console:address, 2:address:editor-data
+  ]
+  screen-should-contain [
+    .          .
+    .0123      .
+    .┈┈┈┈┈┈┈┈┈┈.
+    .          .
+  ]
+]
+
 after +handle-redo [
   {
     typing:address:insert-operation <- maybe-convert *op, typing:variant