File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -602,6 +602,17 @@ impl CommandLine {
602
602
}
603
603
}
604
604
605
+ pub fn cursor_back ( & mut self ) {
606
+ if self . cursor > 1 {
607
+ self . cursor = 1 ;
608
+ self . autocomplete . invalidate ( ) ;
609
+ }
610
+ }
611
+
612
+ pub fn cursor_front ( & mut self ) {
613
+ self . cursor = self . input . len ( ) ;
614
+ }
615
+
605
616
pub fn putc ( & mut self , c : char ) {
606
617
if self . input . len ( ) + c. len_utf8 ( ) > self . input . capacity ( ) {
607
618
return ;
@@ -1334,6 +1345,19 @@ mod test {
1334
1345
1335
1346
cli. delc ( ) ;
1336
1347
assert_eq ! ( cli. input( ) , ":e" ) ;
1348
+
1349
+ cli. clear ( ) ;
1350
+ cli. puts ( ":echo" ) ;
1351
+
1352
+ assert_eq ! ( cli. peek( ) , None ) ;
1353
+ cli. cursor_back ( ) ;
1354
+
1355
+ assert_eq ! ( cli. peek( ) , Some ( 'e' ) ) ;
1356
+ assert_eq ! ( cli. peek_back( ) , Some ( ':' ) ) ;
1357
+
1358
+ cli. cursor_front ( ) ;
1359
+ assert_eq ! ( cli. peek( ) , None ) ;
1360
+ assert_eq ! ( cli. peek_back( ) , Some ( 'o' ) ) ;
1337
1361
}
1338
1362
1339
1363
#[ test]
Original file line number Diff line number Diff line change @@ -2286,6 +2286,12 @@ impl Session {
2286
2286
platform:: Key :: Escape => {
2287
2287
self . cmdline_hide ( ) ;
2288
2288
}
2289
+ platform:: Key :: Home => {
2290
+ self . cmdline . cursor_back ( ) ;
2291
+ }
2292
+ platform:: Key :: End => {
2293
+ self . cmdline . cursor_front ( ) ;
2294
+ }
2289
2295
_ => { }
2290
2296
}
2291
2297
}
You can’t perform that action at this time.
0 commit comments