From a39f59548a1751faeeb423d9590d8c93e80075dd Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 15 Jun 2017 21:02:51 -0700 Subject: 3913 Bugfix in ctrl-u. --- edit/003-shortcuts.mu | 47 +++++++++++++++++++++++++++++++++++++++++++++-- sandbox/003-shortcuts.mu | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 90 insertions(+), 4 deletions(-) diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu index c85d34c9..e46b470c 100644 --- a/edit/003-shortcuts.mu +++ b/edit/003-shortcuts.mu @@ -1681,12 +1681,12 @@ after [ deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor - 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 @@ -1708,6 +1708,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 @@ -1887,6 +1894,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 [ 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 [ deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor - 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 [ -- cgit 1.4.1-2-gfad0