about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-01 16:16:35 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-01 20:09:11 -0700
commit1a8430cdaef2dbc6a42439f3d29ea37f71ce5853 (patch)
treec8fc613de50664ff76456d7047a4964e9a224ac2
parent93752d9d030c22e95bb8daca353138b76faddd95 (diff)
downloadmu-1a8430cdaef2dbc6a42439f3d29ea37f71ce5853.tar.gz
2123 - bugfix in wrapping current line
-rw-r--r--edit.mu34
1 files changed, 33 insertions, 1 deletions
diff --git a/edit.mu b/edit.mu
index 30131253..60545fea 100644
--- a/edit.mu
+++ b/edit.mu
@@ -811,7 +811,7 @@ recipe insert-at-cursor [
     curr-column:number <- copy save-column
     {
       # hit right margin? give up and let caller render
-      at-right?:boolean <- greater-or-equal curr-column, screen-width
+      at-right?:boolean <- greater-than curr-column, right
       reply-if at-right?, editor/same-as-ingredient:0, screen/same-as-ingredient:2, 1/go-render
       break-unless curr
       # newline? done.
@@ -1197,6 +1197,38 @@ scenario editor-wraps-line-on-insert [
   ]
 ]
 
+scenario editor-wraps-line-on-insert-2 [
+  # create an editor with some text
+  assume-screen 10/width, 5/height
+  1:address:array:character <- new [abcdefg
+defg]
+  2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right
+  editor-render screen, 2:address:editor-data
+  # type more text at the start
+  assume-console [
+    left-click 3, 0
+    type [abc]
+  ]
+  run [
+    editor-event-loop screen:address, console:address, 2:address:editor-data
+    3:number <- get *2:address:editor-data, cursor-row:offset
+    4:number <- get *2:address:editor-data, cursor-column:offset
+  ]
+  # cursor is not wrapped
+  memory-should-contain [
+    3 <- 3
+    4 <- 3
+  ]
+  # but line is wrapped
+  screen-should-contain [
+    .          .
+    .abcd↩     .
+    .efg       .
+    .abcd↩     .
+    .efg       .
+  ]
+]
+
 after +insert-character-special-case [
   # if the line wraps at the cursor, move cursor to start of next row
   {