@@ -268,7 +268,7 @@ mod test {
268
268
#[ allow( non_snake_case) ]
269
269
mod integration {
270
270
use super :: * ;
271
- use crate :: { Editor , ReedlineEvent , UndoBehavior } ;
271
+ use crate :: { Reedline , ReedlineEvent } ;
272
272
use pretty_assertions:: assert_eq;
273
273
use rstest:: rstest;
274
274
@@ -279,7 +279,7 @@ mod test {
279
279
ReedlineEvent :: Multiple ( events) => {
280
280
events. into_iter ( ) . flat_map ( unwrap_edits) . collect ( )
281
281
}
282
- other => panic ! ( "unexpected event $ {other}" ) ,
282
+ other => panic ! ( "unexpected event {other:#? }" ) ,
283
283
}
284
284
}
285
285
@@ -292,9 +292,16 @@ mod test {
292
292
"^" , "dw" , "P" , "P" , "b" ,
293
293
// run the actual test, and it should put us back where we started.
294
294
"dw" , "dw" , "P" ] ) ]
295
- #[ case:: edit_ddu( & [ "dd" , "u" ] ) ]
295
+ #[ case:: edit_dd_u( & [ "dd" , "u" ] ) ]
296
+ // not actually a no-op because it adds a newline, but we .trim_end()
297
+ #[ case:: edit_dd_p( & [ "dd" , "p" ] ) ]
298
+ #[ case:: edit_dd_P_uu( & [ "dd" , "P" , "u" , "u" ] ) ]
299
+ // FIXME: this happens on the second line, so doesn't actually delete two lines
300
+ // I can't work out how to use "k" to go to the line above because it generates an
301
+ // UntilFound([MenuUp, Up]) event, and I'm not sure how to handle that.
302
+ #[ case:: edit_d2d_p( & [ "d2d" , "p" ] ) ]
296
303
fn sum_to_zero ( #[ case] commands : & [ & str ] ) {
297
- let initial_input = "the quick brown fox jumps over the lazy dog" ;
304
+ let initial_input = "the quick brown fox\n jumps over the lazy dog" ;
298
305
let keybindings = default_vi_normal_keybindings ( ) ;
299
306
let mut vi = Vi {
300
307
insert_keybindings : default_vi_insert_keybindings ( ) ,
@@ -303,21 +310,18 @@ mod test {
303
310
..Default :: default ( )
304
311
} ;
305
312
306
- let mut editor = Editor :: default ( ) ;
307
- editor . set_buffer ( initial_input. to_string ( ) , UndoBehavior :: CreateUndoPoint ) ;
313
+ let mut reedline = Reedline :: create ( ) ;
314
+ reedline . run_edit_commands ( & [ EditCommand :: InsertString ( initial_input. into ( ) ) ] ) ;
308
315
309
316
for command in commands {
310
317
let command: Vec < char > = command. chars ( ) . collect ( ) ;
311
318
let parsed = parse ( & mut command. iter ( ) . peekable ( ) ) ;
312
319
let commands = unwrap_edits ( parsed. to_reedline_event ( & mut vi) ) ;
313
- // FIXME: use run_edit_commands() instead
314
- for command in commands {
315
- editor. run_edit_command ( & command)
316
- }
320
+
321
+ reedline. run_edit_commands ( & commands)
317
322
}
318
323
319
- // FIXME: use Engine::current_buffer_contents()
320
- assert_eq ! ( initial_input, editor. get_buffer( ) ) ;
324
+ assert_eq ! ( initial_input, reedline. current_buffer_contents( ) . trim_end( ) ) ;
321
325
}
322
326
}
323
327
}
0 commit comments