about summary refs log tree commit diff stats
path: root/edit
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-10 20:47:09 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-10 20:47:09 -0800
commit080e9cb73fa55cdc862f1dd7593df56e0a6302b8 (patch)
tree67a3ee4b44dc61d40b10e62c34ddda45dbb41df2 /edit
parent17b90929307614a8691f680e5ada165fd5b4db53 (diff)
downloadmu-080e9cb73fa55cdc862f1dd7593df56e0a6302b8.tar.gz
2422 - a bugfix from the last lesson
Thanks Caleb Couch. This one's been on my list for 2 weeks.
Diffstat (limited to 'edit')
-rw-r--r--edit/003-shortcuts.mu60
1 files changed, 59 insertions, 1 deletions
diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu
index 88a67e26..f4c480d3 100644
--- a/edit/003-shortcuts.mu
+++ b/edit/003-shortcuts.mu
@@ -110,7 +110,7 @@ recipe delete-before-cursor editor:address:editor-data, screen:address:screen ->
   curr-column:number <- copy cursor-column
   {
     # hit right margin? give up and let caller render
-    at-right?:boolean <- greater-or-equal curr-column, screen-width
+    at-right?:boolean <- greater-or-equal curr-column, right
     go-render? <- copy 1/true
     reply-if at-right?
     break-unless curr
@@ -223,6 +223,64 @@ cd]
   ]
 ]
 
+scenario editor-joins-and-wraps-lines-on-backspace [
+  assume-screen 10/width, 5/height
+  # initialize editor with two long-ish but non-wrapping lines
+  1:address:array:character <- new [abc def
+ghi jkl]
+  2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right
+  editor-render screen, 2:address:editor-data
+  $clear-trace
+  # position the cursor at the start of the second and hit backspace
+  assume-console [
+    left-click 2, 0
+    press backspace
+  ]
+  run [
+    editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data
+  ]
+  # resulting single line should wrap correctly
+  screen-should-contain [
+    .          .
+    .abc defgh↩.
+    .i jkl     .
+    .┈┈┈┈┈┈┈┈┈┈.
+    .          .
+  ]
+]
+
+scenario editor-wraps-long-lines-on-backspace [
+  assume-screen 10/width, 5/height
+  # initialize editor in part of the screen with a long line
+  1:address:array:character <- new [abc def ghij]
+  2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 8/right
+  editor-render screen, 2:address:editor-data
+  # confirm that it wraps
+  screen-should-contain [
+    .          .
+    .abc def↩  .
+    . ghij     .
+    .┈┈┈┈┈┈┈┈  .
+  ]
+  $clear-trace
+  # position the cursor somewhere in the middle of the top screen line and hit backspace
+  assume-console [
+    left-click 1, 4
+    press backspace
+  ]
+  run [
+    editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data
+  ]
+  # resulting single line should wrap correctly and not overflow its bounds
+  screen-should-contain [
+    .          .
+    .abcdef ↩  .
+    .ghij      .
+    .┈┈┈┈┈┈┈┈  .
+    .          .
+  ]
+]
+
 # delete - delete character at cursor
 
 scenario editor-handles-delete-key [