@@ -231,6 +231,13 @@ impl TextArea {
231
231
code : KeyCode :: Enter ,
232
232
..
233
233
} => self . insert_str ( "\n " ) ,
234
+ KeyEvent {
235
+ code : KeyCode :: Char ( 'h' ) ,
236
+ modifiers,
237
+ ..
238
+ } if modifiers == ( KeyModifiers :: CONTROL | KeyModifiers :: ALT ) => {
239
+ self . delete_backward_word ( )
240
+ } ,
234
241
KeyEvent {
235
242
code : KeyCode :: Backspace ,
236
243
modifiers : KeyModifiers :: ALT ,
@@ -1171,6 +1178,30 @@ mod tests {
1171
1178
assert_eq ! ( t. cursor( ) , 2 ) ;
1172
1179
}
1173
1180
1181
+ #[ test]
1182
+ fn delete_backward_word_alt_keys ( ) {
1183
+ use crossterm:: event:: KeyCode ;
1184
+ use crossterm:: event:: KeyEvent ;
1185
+ use crossterm:: event:: KeyModifiers ;
1186
+
1187
+ // Test the custom Alt+Ctrl+h binding
1188
+ let mut t = ta_with ( "hello world" ) ;
1189
+ t. set_cursor ( t. text ( ) . len ( ) ) ; // cursor at the end
1190
+ t. input ( KeyEvent :: new (
1191
+ KeyCode :: Char ( 'h' ) ,
1192
+ KeyModifiers :: CONTROL | KeyModifiers :: ALT ,
1193
+ ) ) ;
1194
+ assert_eq ! ( t. text( ) , "hello " ) ;
1195
+ assert_eq ! ( t. cursor( ) , 6 ) ;
1196
+
1197
+ // Test the standard Alt+Backspace binding
1198
+ let mut t = ta_with ( "hello world" ) ;
1199
+ t. set_cursor ( t. text ( ) . len ( ) ) ; // cursor at the end
1200
+ t. input ( KeyEvent :: new ( KeyCode :: Backspace , KeyModifiers :: ALT ) ) ;
1201
+ assert_eq ! ( t. text( ) , "hello " ) ;
1202
+ assert_eq ! ( t. cursor( ) , 6 ) ;
1203
+ }
1204
+
1174
1205
#[ test]
1175
1206
fn cursor_vertical_movement_across_lines_and_bounds ( ) {
1176
1207
let mut t = ta_with ( "short\n loooooooooong\n mid" ) ;
0 commit comments