@@ -102,6 +102,8 @@ impl Editor {
102
102
EditCommand :: SelectAll => self . select_all ( ) ,
103
103
EditCommand :: CutSelection => self . cut_selection ( ) ,
104
104
EditCommand :: CopySelection => self . copy_selection ( ) ,
105
+ EditCommand :: SelectMoveWordLeft => self . select_move_word_left ( ) ,
106
+ EditCommand :: SelectMoveWordRight => self . select_move_word_right ( ) ,
105
107
}
106
108
107
109
let new_undo_behavior = match ( command, command. edit_type ( ) ) {
@@ -120,7 +122,11 @@ impl Editor {
120
122
} ;
121
123
if !matches ! (
122
124
command,
123
- EditCommand :: SelectMoveLeft | EditCommand :: SelectMoveRight | EditCommand :: SelectAll
125
+ EditCommand :: SelectMoveLeft
126
+ | EditCommand :: SelectMoveRight
127
+ | EditCommand :: SelectMoveWordLeft
128
+ | EditCommand :: SelectMoveWordRight
129
+ | EditCommand :: SelectAll
124
130
) {
125
131
self . reset_selection ( ) ;
126
132
}
@@ -545,6 +551,20 @@ impl Editor {
545
551
}
546
552
} )
547
553
}
554
+
555
+ fn select_move_word_left ( & mut self ) {
556
+ if self . selection_anchor . is_none ( ) {
557
+ self . selection_anchor = Some ( self . insertion_point ( ) ) ;
558
+ }
559
+ self . line_buffer . move_word_left ( ) ;
560
+ }
561
+
562
+ fn select_move_word_right ( & mut self ) {
563
+ if self . selection_anchor . is_none ( ) {
564
+ self . selection_anchor = Some ( self . insertion_point ( ) ) ;
565
+ }
566
+ self . line_buffer . move_word_right ( ) ;
567
+ }
548
568
}
549
569
550
570
#[ cfg( test) ]
0 commit comments