@@ -27,6 +27,8 @@ use crate::{Application, Env, MouseEvent, PaintCtx, Point, Rect, UpdateCtx};
2727/// `Editor` manages an [`EditableText`] type, applying edits and maintaining
2828/// selection state.
2929///
30+ /// The type parameter `T` is the text data being edited.
31+ ///
3032/// [`EditableText`]: trait.EditableText.html
3133#[ derive( Debug , Clone ) ]
3234pub struct Editor < T > {
@@ -64,7 +66,6 @@ impl<T> Editor<T> {
6466 self . layout . set_wrap_width ( width) ;
6567 }
6668
67- //TODO discussion: should this deref/deref_mut?
6869 /// Return the inner [`TextLayout`] objects.
6970 ///
7071 /// [`TextLayout`]: struct.TextLayout.html
@@ -191,7 +192,7 @@ impl<T: TextStorage + EditableText> Editor<T> {
191192 }
192193 }
193194 EditAction :: Drag ( action) => self . selection . end = action. column ,
194- _ => ( ) ,
195+ EditAction :: SelectAll => self . selection = Selection :: new ( 0 , data . len ( ) ) ,
195196 }
196197 }
197198
@@ -222,8 +223,7 @@ impl<T: TextStorage + EditableText> Editor<T> {
222223 self . selection = Selection :: caret ( self . selection . min ( ) + text. len ( ) ) ;
223224 }
224225
225- /// Delete to previous grapheme if in caret mode.
226- /// Otherwise just delete everything inside the selection.
226+ /// Delete backwards, using fancy logic when in caret mode.
227227 fn delete_backward ( & mut self , data : & mut T ) {
228228 let cursor_pos = if self . selection . is_caret ( ) {
229229 let del_end = self . selection . end ;
@@ -240,7 +240,7 @@ impl<T: TextStorage + EditableText> Editor<T> {
240240
241241 fn delete_forward ( & mut self , data : & mut T ) {
242242 let to_delete = if self . selection . is_caret ( ) {
243- movement ( Movement :: Right , self . selection , data, false )
243+ movement ( Movement :: Right , self . selection , data, true )
244244 } else {
245245 self . selection
246246 } ;
0 commit comments