about summary refs log tree commit diff stats
path: root/edit
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-06-24 15:48:57 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-06-24 15:48:57 -0700
commitd467b0a5b2ebf4e3bbfb510ca317e6141cce0d06 (patch)
treee92777b1263c380dc4f93e1472db43cbb845ce7d /edit
parentc4cff3b3555e509ecbefa3d2298a54758f687bf5 (diff)
downloadmu-d467b0a5b2ebf4e3bbfb510ca317e6141cce0d06.tar.gz
3950
Fix a regression caused by commit 3919.

Thanks Juan Crispin Hernandez for running into this.
Diffstat (limited to 'edit')
-rw-r--r--edit/003-shortcuts.mu45
1 files changed, 43 insertions, 2 deletions
diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu
index d65fc7e4..abae4b3f 100644
--- a/edit/003-shortcuts.mu
+++ b/edit/003-shortcuts.mu
@@ -1017,7 +1017,8 @@ def move-to-previous-line editor:&:editor -> go-render?:bool, editor:&:editor [
     curr:&:duplex-list:char <- copy before-cursor
     old:&:duplex-list:char <- copy curr
     {
-      break-unless cursor-column
+      at-left?:bool <- equal cursor-column, left
+      break-if at-left?
       curr <- before-previous-screen-line curr, editor
       no-motion?:bool <- equal curr, old
       return-if no-motion?
@@ -1134,7 +1135,7 @@ def]
   ]
 ]
 
-scenario editor-moves-to-previous-line-from-left-margin [
+scenario editor-moves-to-previous-line-from-zero-margin [
   local-scope
   assume-screen 10/width, 5/height
   # start out with three lines
@@ -1174,6 +1175,46 @@ ghi]
   ]
 ]
 
+scenario editor-moves-to-previous-line-from-left-margin [
+  local-scope
+  assume-screen 10/width, 5/height
+  # start out with three lines
+  s:text <- new [abc
+def
+ghi]
+  e:&:editor <- new-editor s, 1/left, 10/right
+  editor-render screen, e
+  $clear-trace
+  # click on the third line and hit up-arrow, so you end up just after a newline
+  assume-console [
+    left-click 3, 1
+    press up-arrow
+  ]
+  run [
+    editor-event-loop screen, console, e
+    3:num/raw <- get *e, cursor-row:offset
+    4:num/raw <- get *e, cursor-column:offset
+  ]
+  memory-should-contain [
+    3 <- 2
+    4 <- 1
+  ]
+  check-trace-count-for-label 0, [print-character]
+  assume-console [
+    type [0]
+  ]
+  run [
+    editor-event-loop screen, console, e
+  ]
+  screen-should-contain [
+    .          .
+    . abc      .
+    . 0def     .
+    . ghi      .
+    . ┈┈┈┈┈┈┈┈┈.
+  ]
+]
+
 scenario editor-moves-to-top-line-in-presence-of-wrapped-line [
   local-scope
   assume-screen 10/width, 5/height