about summary refs log tree commit diff stats
path: root/sandbox
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-06-15 21:02:51 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-06-15 21:02:51 -0700
commita39f59548a1751faeeb423d9590d8c93e80075dd (patch)
treee1601d0d48e2fcea0873d1d3ef3ae8ef40c06b3d /sandbox
parent778787eadfc45c298afdd9475e2d52a2cf683e4e (diff)
downloadmu-a39f59548a1751faeeb423d9590d8c93e80075dd.tar.gz
3913
Bugfix in ctrl-u.
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/003-shortcuts.mu47
1 files changed, 45 insertions, 2 deletions
diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu
index 076414a1..d8e804f0 100644
--- a/sandbox/003-shortcuts.mu
+++ b/sandbox/003-shortcuts.mu
@@ -1656,12 +1656,12 @@ after <handle-special-character> [
     <delete-to-start-of-line-begin>
     deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor
     <delete-to-start-of-line-end>
-    go-render?:bool <- minimal-render-for-ctrl-u screen, editor
+    go-render?:bool <- minimal-render-for-ctrl-u screen, editor, deleted-cells
     return
   }
 ]
 
-def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor -> go-render?:bool, screen:&:screen [
+def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor, deleted-cells:&:duplex-list:char -> go-render?:bool, screen:&:screen [
   local-scope
   load-ingredients
   curr-column:num <- get *editor, cursor-column:offset
@@ -1683,6 +1683,13 @@ def minimal-render-for-ctrl-u screen:&:screen, editor:&:editor -> go-render?:boo
     i <- add i, 1
     loop
   }
+  # if the line used to be wrapped, give up and render the whole screen
+  num-deleted-cells:num <- length deleted-cells
+  old-row-len:num <- add i, num-deleted-cells
+  left:num <- get *editor, left:offset
+  end:num <- subtract right, left
+  wrap?:bool <- greater-or-equal old-row-len, end
+  return-if wrap?, 1/go-render
   curr-line:text <- buffer-to-array buf
   curr-row:num <- get *editor, cursor-row:offset
   render-code screen, curr-line, curr-column, right, curr-row
@@ -1862,6 +1869,42 @@ scenario editor-deletes-to-start-of-final-line-with-ctrl-u [
   check-trace-count-for-label 10, [print-character]
 ]
 
+scenario editor-deletes-to-start-of-wrapped-line-with-ctrl-u [
+  local-scope
+  assume-screen 10/width, 10/height
+  # first line starts out wrapping
+  s:text <- new [123456
+789]
+  e:&:editor <- new-editor s, 0/left, 5/right
+  editor-render screen, e
+  screen-should-contain [
+    .          .
+    .1234↩     .
+    .56        .
+    .789       .
+    .┈┈┈┈┈     .
+    .          .
+  ]
+  $clear-trace
+  # ctrl-u enough of the first line that it's no longer wrapping
+  assume-console [
+    left-click 1, 3
+    press ctrl-u
+  ]
+  run [
+    editor-event-loop screen, console, e
+  ]
+  # entire screen needs to be refreshed
+  screen-should-contain [
+    .          .
+    .456       .
+    .789       .
+    .┈┈┈┈┈     .
+    .          .
+  ]
+  check-trace-count-for-label 45, [print-character]
+]
+
 # ctrl-k - delete text from cursor to end of line (but not the newline)
 
 scenario editor-deletes-to-end-of-line-with-ctrl-k [