@@ -26,7 +26,7 @@ use helix_view::{
26
26
keyboard:: { KeyCode , KeyModifiers } ,
27
27
Document , Editor , Theme , View ,
28
28
} ;
29
- use std:: { borrow:: Cow , path:: PathBuf } ;
29
+ use std:: { borrow:: Cow , cmp :: min , num :: NonZeroUsize , path:: PathBuf } ;
30
30
31
31
use tui:: buffer:: Buffer as Surface ;
32
32
@@ -1056,37 +1056,40 @@ impl EditorView {
1056
1056
}
1057
1057
// special handling for repeat operator
1058
1058
( key ! ( '.' ) , _) if self . keymaps . pending ( ) . is_empty ( ) => {
1059
- // first execute whatever put us into insert mode
1060
- self . last_insert . 0 . execute ( cxt) ;
1061
- // then replay the inputs
1062
- for key in self . last_insert . 1 . clone ( ) {
1063
- match key {
1064
- InsertEvent :: Key ( key) => self . insert_mode ( cxt, key) ,
1065
- InsertEvent :: CompletionApply ( compl) => {
1066
- let ( view, doc) = current ! ( cxt. editor) ;
1067
-
1068
- doc. restore ( view) ;
1069
-
1070
- let text = doc. text ( ) . slice ( ..) ;
1071
- let cursor = doc. selection ( view. id ) . primary ( ) . cursor ( text) ;
1072
-
1073
- let shift_position =
1074
- |pos : usize | -> usize { pos + cursor - compl. trigger_offset } ;
1075
-
1076
- let tx = Transaction :: change (
1077
- doc. text ( ) ,
1078
- compl. changes . iter ( ) . cloned ( ) . map ( |( start, end, t) | {
1079
- ( shift_position ( start) , shift_position ( end) , t)
1080
- } ) ,
1081
- ) ;
1082
- apply_transaction ( & tx, doc, view) ;
1083
- }
1084
- InsertEvent :: TriggerCompletion => {
1085
- let ( _, doc) = current ! ( cxt. editor) ;
1086
- doc. savepoint ( ) ;
1059
+ for _ in 0 ..cxt. editor . count . map_or ( 1 , NonZeroUsize :: into) {
1060
+ // first execute whatever put us into insert mode
1061
+ self . last_insert . 0 . execute ( cxt) ;
1062
+ // then replay the inputs
1063
+ for key in self . last_insert . 1 . clone ( ) {
1064
+ match key {
1065
+ InsertEvent :: Key ( key) => self . insert_mode ( cxt, key) ,
1066
+ InsertEvent :: CompletionApply ( compl) => {
1067
+ let ( view, doc) = current ! ( cxt. editor) ;
1068
+
1069
+ doc. restore ( view) ;
1070
+
1071
+ let text = doc. text ( ) . slice ( ..) ;
1072
+ let cursor = doc. selection ( view. id ) . primary ( ) . cursor ( text) ;
1073
+
1074
+ let shift_position =
1075
+ |pos : usize | -> usize { pos + cursor - compl. trigger_offset } ;
1076
+
1077
+ let tx = Transaction :: change (
1078
+ doc. text ( ) ,
1079
+ compl. changes . iter ( ) . cloned ( ) . map ( |( start, end, t) | {
1080
+ ( shift_position ( start) , shift_position ( end) , t)
1081
+ } ) ,
1082
+ ) ;
1083
+ apply_transaction ( & tx, doc, view) ;
1084
+ }
1085
+ InsertEvent :: TriggerCompletion => {
1086
+ let ( _, doc) = current ! ( cxt. editor) ;
1087
+ doc. savepoint ( ) ;
1088
+ }
1087
1089
}
1088
1090
}
1089
1091
}
1092
+ cxt. editor . count = None ;
1090
1093
}
1091
1094
_ => {
1092
1095
// set the count
0 commit comments