@@ -512,20 +512,22 @@ impl<H: Helper> State<'_, '_, H> {
512512 struct Proxy < ' p > {
513513 changes : & ' p mut Changeset ,
514514 kill_ring : & ' p mut KillRing ,
515- layout : & ' p Layout ,
516- pos : usize ,
517- cursor_shift : Unit ,
518- end_shift : Unit ,
519- trivial : bool ,
515+ layout : & ' p Layout , // current layout (before kill)
516+ pos : usize , // current cursor (byte) position (before kill)
517+ end : usize , // end (before kill)
518+ cursor_shift : Unit , // cursor shift (columns) after kill
519+ end_shift : Unit , // end of line shift (columns) after kill
520+ trivial : bool , // true if a partial screen update can be done
520521 }
521522 let mut proxy = Proxy {
522523 changes : & mut self . changes ,
523524 kill_ring,
524525 layout : & self . layout ,
525526 pos : self . line . pos ( ) ,
527+ end : self . line . len ( ) ,
526528 cursor_shift : 0 ,
527529 end_shift : 0 ,
528- trivial : true ,
530+ trivial : self . layout . cursor . row == self . layout . end . row ,
529531 } ;
530532 impl DeleteListener for Proxy < ' _ > {
531533 fn start_killing ( & mut self ) {
@@ -535,14 +537,22 @@ impl<H: Helper> State<'_, '_, H> {
535537 fn delete ( & mut self , idx : usize , string : & str , dir : Direction ) {
536538 self . changes . delete ( idx, string) ;
537539 self . kill_ring . delete ( idx, string, dir) ;
538- if dir == Direction :: Backward {
539- let width = self . layout . width ( string) ;
540- self . cursor_shift += width;
541- self . end_shift += width;
542- } else if idx == self . pos {
543- self . end_shift += self . layout . width ( string) ;
544- } else {
545- self . trivial = false ;
540+ if self . trivial {
541+ if dir == Direction :: Backward {
542+ if self . pos == self . end {
543+ // backward from eol
544+ let width = self . layout . width ( string) ;
545+ self . cursor_shift += width;
546+ self . end_shift += width;
547+ } else {
548+ self . trivial = false ;
549+ }
550+ } else if idx == self . pos && self . pos + string. len ( ) == self . end {
551+ // forward to eol
552+ self . end_shift += self . layout . width ( string) ;
553+ } else {
554+ self . trivial = false ;
555+ }
546556 }
547557 }
548558
@@ -556,14 +566,13 @@ impl<H: Helper> State<'_, '_, H> {
556566 let no_previous_hint = self . hint . is_none ( ) ;
557567 self . hint ( ) ;
558568 if trivial
559- && self . layout . cursor . row == self . layout . end . row
560- && self . line . is_cursor_at_end ( )
561569 && cursor_shift <= self . layout . cursor . col
562570 && end_shift <= self . layout . end . col
563571 && ( self . hint . is_none ( ) && no_previous_hint)
564572 && !self . highlight_char ( CmdKind :: Other )
565573 {
566574 // Avoid a full update of the line in the trivial case.
575+ debug_assert ! ( self . line. is_cursor_at_end( ) ) ;
567576 if cursor_shift != 0 {
568577 let old = self . layout . cursor ;
569578 self . layout . cursor . col -= cursor_shift;
0 commit comments