@@ -215,3 +215,160 @@ async fn test_multi_selection_paste() -> anyhow::Result<()> {
215
215
216
216
Ok ( ( ) )
217
217
}
218
+
219
+
220
+ // Line selection movement tests
221
+
222
+ #[ tokio:: test( flavor = "multi_thread" ) ]
223
+ async fn test_move_selection_single_selection_up ( ) -> anyhow:: Result < ( ) > {
224
+ test ( (
225
+ platform_line ( indoc ! {
226
+ "aaaaaa
227
+ bbbbbb
228
+ cc#[|c]#ccc
229
+ dddddd
230
+ " } )
231
+ . as_str ( ) ,
232
+ "<C-up>" ,
233
+ platform_line ( indoc ! {
234
+ "aaaaaa
235
+ cc#[|c]#ccc
236
+ bbbbbb
237
+ dddddd
238
+ " } )
239
+ . as_str ( ) ,
240
+ ) ) . await ?;
241
+ Ok ( ( ) )
242
+ }
243
+
244
+ #[ tokio:: test( flavor = "multi_thread" ) ]
245
+ async fn test_move_selection_single_selection_down ( ) -> anyhow:: Result < ( ) > {
246
+ test ( (
247
+ platform_line ( indoc ! {
248
+ "aa#[|a]#aaa
249
+ bbbbbb
250
+ cccccc
251
+ dddddd
252
+ " } )
253
+ . as_str ( ) ,
254
+ "<C-down>" ,
255
+ platform_line ( indoc ! {
256
+ "bbbbbb
257
+ aa#[|a]#aaa
258
+ cccccc
259
+ dddddd
260
+ " } )
261
+ . as_str ( ) ,
262
+ ) ) . await ?;
263
+ Ok ( ( ) )
264
+ }
265
+
266
+ #[ tokio:: test( flavor = "multi_thread" ) ]
267
+ async fn test_move_selection_single_selection_top_up ( ) -> anyhow:: Result < ( ) > {
268
+ // if already on top of the file and going up, nothing should change
269
+ test ( (
270
+ platform_line ( indoc ! {
271
+ "aa#[|a]#aaa
272
+ bbbbbb
273
+ cccccc
274
+ dddddd" } )
275
+ . as_str ( ) ,
276
+ "<C-up>" ,
277
+ platform_line ( indoc ! {
278
+ "aa#[|a]#aaa
279
+ bbbbbb
280
+ cccccc
281
+ dddddd" } )
282
+ . as_str ( ) ,
283
+ ) ) . await ?;
284
+ Ok ( ( ) )
285
+ }
286
+
287
+ #[ tokio:: test( flavor = "multi_thread" ) ]
288
+ async fn test_move_selection_single_selection_bottom_down ( ) -> anyhow:: Result < ( ) > {
289
+ // If going down on the bottom line, nothing should change
290
+ // Note that platform_line is not used here, because it inserts trailing
291
+ // linebreak, making it impossible to test
292
+ test ( (
293
+ "aaaaaa\n bbbbbb\n cccccc\n dd#[|d]#ddd" ,
294
+ "<C-down><C-down>" ,
295
+ "aaaaaa\n bbbbbb\n cccccc\n dd#[|d]#ddd"
296
+ ) ) . await ?;
297
+
298
+ Ok ( ( ) )
299
+ }
300
+
301
+ #[ tokio:: test( flavor = "multi_thread" ) ]
302
+ async fn test_move_selection_block_down ( ) -> anyhow:: Result < ( ) > {
303
+ test ( (
304
+ platform_line ( indoc ! { "
305
+ #[|aaaaaa
306
+ bbbbbb
307
+ ccc]#ccc
308
+ dddddd
309
+ eeeeee
310
+ " } )
311
+ . as_str ( ) ,
312
+ "<C-down>" ,
313
+ platform_line ( indoc ! { "
314
+ dddddd
315
+ #[|aaaaaa
316
+ bbbbbb
317
+ ccc]#ccc
318
+ eeeeee
319
+ " } )
320
+ . as_str ( ) ,
321
+ ) ) . await ?;
322
+
323
+ Ok ( ( ) )
324
+ }
325
+
326
+ #[ tokio:: test( flavor = "multi_thread" ) ]
327
+ async fn test_move_selection_block_up ( ) -> anyhow:: Result < ( ) > {
328
+ test ( (
329
+ platform_line ( indoc ! { "
330
+ aaaaaa
331
+ bb#[bbbb
332
+ ccc|]#ccc
333
+ dddddd
334
+ eeeeee
335
+ " } )
336
+ . as_str ( ) ,
337
+ "<C-up>" ,
338
+ platform_line ( indoc ! { "
339
+ bb#[bbbb
340
+ ccc|]#ccc
341
+ aaaaaa
342
+ dddddd
343
+ eeeeee
344
+ " } )
345
+ . as_str ( ) ,
346
+ ) ) . await ?;
347
+
348
+ Ok ( ( ) )
349
+ }
350
+
351
+ #[ tokio:: test( flavor = "multi_thread" ) ]
352
+ async fn test_move_two_cursors_down ( ) -> anyhow:: Result < ( ) > {
353
+ test ( (
354
+ platform_line ( indoc ! { "
355
+ aaaaaa
356
+ bb#[|b]#bbb
357
+ cccccc
358
+ d#(dd|)#ddd
359
+ eeeeee
360
+ " } )
361
+ . as_str ( ) ,
362
+ "<C-down>" ,
363
+ platform_line ( indoc ! { "
364
+ aaaaaa
365
+ cccccc
366
+ bb#[|b]#bbb
367
+ eeeeee
368
+ d#(dd|)#ddd
369
+ " } )
370
+ . as_str ( ) ,
371
+ ) ) . await ?;
372
+
373
+ Ok ( ( ) )
374
+ }
0 commit comments