@@ -413,4 +413,39 @@ mod tests {
413
413
harp:: parse_eval ( "remove(my_fun)" , options. clone ( ) ) . unwrap ( ) ;
414
414
} )
415
415
}
416
+
417
+ #[ test]
418
+ fn test_completions_multiline ( ) {
419
+ r_task ( || {
420
+ // No arguments typed yet
421
+ let ( text, point) = point_from_cursor ( "match(\n @\n )" ) ;
422
+ let document = Document :: new ( text. as_str ( ) , None ) ;
423
+ let context = DocumentContext :: new ( & document, point, None ) ;
424
+ let completions = completions_from_call ( & context, None ) . unwrap ( ) . unwrap ( ) ;
425
+
426
+ assert_eq ! ( completions. len( ) , 4 ) ;
427
+ assert_eq ! ( completions. get( 0 ) . unwrap( ) . label, "x = " ) ;
428
+ assert_eq ! ( completions. get( 1 ) . unwrap( ) . label, "table = " ) ;
429
+
430
+ // Partially typed argument
431
+ let ( text, point) = point_from_cursor ( "match(\n tab@\n )" ) ;
432
+ let document = Document :: new ( text. as_str ( ) , None ) ;
433
+ let context = DocumentContext :: new ( & document, point, None ) ;
434
+ let completions = completions_from_call ( & context, None ) . unwrap ( ) . unwrap ( ) ;
435
+
436
+ assert_eq ! ( completions. len( ) , 4 ) ;
437
+ assert_eq ! ( completions. get( 0 ) . unwrap( ) . label, "x = " ) ;
438
+ assert_eq ! ( completions. get( 1 ) . unwrap( ) . label, "table = " ) ;
439
+
440
+ // Partially typed second argument
441
+ let ( text, point) = point_from_cursor ( "match(\n 1,\n tab@\n )" ) ;
442
+ let document = Document :: new ( text. as_str ( ) , None ) ;
443
+ let context = DocumentContext :: new ( & document, point, None ) ;
444
+ let completions = completions_from_call ( & context, None ) . unwrap ( ) . unwrap ( ) ;
445
+
446
+ assert_eq ! ( completions. len( ) , 4 ) ;
447
+ assert_eq ! ( completions. get( 0 ) . unwrap( ) . label, "x = " ) ;
448
+ assert_eq ! ( completions. get( 1 ) . unwrap( ) . label, "table = " ) ;
449
+ } )
450
+ }
416
451
}
0 commit comments