about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-12 20:37:42 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-12 20:37:42 -0800
commit37ebd392532b42877da069a0c7224601ba9cbc2b (patch)
tree8ce66db191457a72597350043d91c536925fa420 /apps/tile
parent2ee741b0d33712cb8d24a5094d630960d1c14a6c (diff)
downloadmu-37ebd392532b42877da069a0c7224601ba9cbc2b.tar.gz
7229 - tile: fix ctrl-e
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/data.mu13
-rw-r--r--apps/tile/environment.mu14
2 files changed, 20 insertions, 7 deletions
diff --git a/apps/tile/data.mu b/apps/tile/data.mu
index 0464c54f..9bf08502 100644
--- a/apps/tile/data.mu
+++ b/apps/tile/data.mu
@@ -619,6 +619,19 @@ fn move-final-element-to-start-of-line list: (addr handle call-path-element) {
   move-final-element-to-start-of-line list
 }
 
+fn move-final-element-to-end-of-line list: (addr handle call-path-element) {
+  var final-ah/eax: (addr handle call-path-element) <- copy list
+  var final/eax: (addr call-path-element) <- lookup *final-ah
+  var val-ah/ecx: (addr handle word) <- get final, word
+  var val/eax: (addr word) <- lookup *val-ah
+  var new-ah/edx: (addr handle word) <- get val, next
+  var target/eax: (addr word) <- lookup *new-ah
+  compare target, 0
+  break-if-=
+  copy-object new-ah, val-ah
+  move-final-element-to-end-of-line list
+}
+
 fn push-to-call-path-element list: (addr handle call-path-element), new: (addr handle word) {
   var new-element-storage: (handle call-path-element)
   var new-element-ah/edi: (addr handle call-path-element) <- address new-element-storage
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index 3a17bcad..64af0c3a 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -351,7 +351,7 @@ $process-sandbox:body: {
     var cursor-call-path-ah/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path
     drop-nested-calls cursor-call-path-ah
     move-final-element-to-start-of-line cursor-call-path-ah
-    # move cursor to start of initial word
+    # move cursor to start of word
     var cursor-call-path/eax: (addr call-path-element) <- lookup *cursor-call-path-ah
     var cursor-word-ah/eax: (addr handle word) <- get cursor-call-path, word
     var cursor-word/eax: (addr word) <- lookup *cursor-word-ah
@@ -363,13 +363,13 @@ $process-sandbox:body: {
   compare key, 5  # ctrl-e
   $process-sandbox:end-of-line: {
     break-if-!=
-    # move cursor to final word of sandbox
-    var cursor-call-path-ah/ecx: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    initialize-path-from-sandbox sandbox, cursor-call-path-ah
+    # move cursor up past all calls and to start of line
+    var cursor-call-path-ah/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path
+    drop-nested-calls cursor-call-path-ah
+    move-final-element-to-end-of-line cursor-call-path-ah
+    # move cursor to end of word
     var cursor-call-path/eax: (addr call-path-element) <- lookup *cursor-call-path-ah
-    var dest/eax: (addr handle word) <- get cursor-call-path, word
-    final-word dest, dest
-    # move cursor to end of final word
+    var cursor-word-ah/eax: (addr handle word) <- get cursor-call-path, word
     var cursor-word/eax: (addr word) <- lookup *cursor-word-ah
     cursor-to-end cursor-word
     # this works because expanded words lie to the right of their bodies