@@ -302,8 +302,8 @@ fn completions_from_workspace_arguments(
302
302
#[ cfg( test) ]
303
303
mod tests {
304
304
use harp:: eval:: RParseEvalOptions ;
305
- use tree_sitter:: Point ;
306
305
306
+ use crate :: fixtures:: point_from_cursor;
307
307
use crate :: lsp:: completions:: sources:: composite:: call:: completions_from_call;
308
308
use crate :: lsp:: document_context:: DocumentContext ;
309
309
use crate :: lsp:: documents:: Document ;
@@ -313,8 +313,8 @@ mod tests {
313
313
fn test_completions_after_user_types_part_of_an_argument_name ( ) {
314
314
r_task ( || {
315
315
// Right after `tab`
316
- let point = Point { row : 0 , column : 9 } ;
317
- let document = Document :: new ( "match(tab)" , None ) ;
316
+ let ( text , point) = point_from_cursor ( "match(tab@)" ) ;
317
+ let document = Document :: new ( text . as_str ( ) , None ) ;
318
318
let context = DocumentContext :: new ( & document, point, None ) ;
319
319
let completions = completions_from_call ( & context, None ) . unwrap ( ) . unwrap ( ) ;
320
320
@@ -324,8 +324,8 @@ mod tests {
324
324
assert_eq ! ( completions. get( 1 ) . unwrap( ) . label, "table = " ) ;
325
325
326
326
// Right after `tab`
327
- let point = Point { row : 0 , column : 12 } ;
328
- let document = Document :: new ( "match(1, tab)" , None ) ;
327
+ let ( text , point) = point_from_cursor ( "match(1, tab@)" ) ;
328
+ let document = Document :: new ( text . as_str ( ) , None ) ;
329
329
let context = DocumentContext :: new ( & document, point, None ) ;
330
330
let completions = completions_from_call ( & context, None ) . unwrap ( ) . unwrap ( ) ;
331
331
@@ -342,8 +342,8 @@ mod tests {
342
342
// Can't find the function
343
343
r_task ( || {
344
344
// Place cursor between `()`
345
- let point = Point { row : 0 , column : 21 } ;
346
- let document = Document :: new ( "not_a_known_function()" , None ) ;
345
+ let ( text , point) = point_from_cursor ( "not_a_known_function(@)" ) ;
346
+ let document = Document :: new ( text . as_str ( ) , None ) ;
347
347
let context = DocumentContext :: new ( & document, point, None ) ;
348
348
let completions = completions_from_call ( & context, None ) . unwrap ( ) ;
349
349
assert ! ( completions. is_none( ) ) ;
@@ -360,8 +360,8 @@ mod tests {
360
360
harp:: parse_eval ( "my_fun <- function(y, x) x + y" , options. clone ( ) ) . unwrap ( ) ;
361
361
362
362
// Place cursor between `()`
363
- let point = Point { row : 0 , column : 7 } ;
364
- let document = Document :: new ( "my_fun()" , None ) ;
363
+ let ( text , point) = point_from_cursor ( "my_fun(@)" ) ;
364
+ let document = Document :: new ( text . as_str ( ) , None ) ;
365
365
let context = DocumentContext :: new ( & document, point, None ) ;
366
366
let completions = completions_from_call ( & context, None ) . unwrap ( ) . unwrap ( ) ;
367
367
@@ -375,15 +375,15 @@ mod tests {
375
375
assert_eq ! ( completion. label, "x = " ) ;
376
376
377
377
// Place just before the `()`
378
- let point = Point { row : 0 , column : 6 } ;
379
- let document = Document :: new ( "my_fun()" , None ) ;
378
+ let ( text , point) = point_from_cursor ( "my_fun@()" ) ;
379
+ let document = Document :: new ( text . as_str ( ) , None ) ;
380
380
let context = DocumentContext :: new ( & document, point, None ) ;
381
381
let completions = completions_from_call ( & context, None ) . unwrap ( ) ;
382
382
assert ! ( completions. is_none( ) ) ;
383
383
384
384
// Place just after the `()`
385
- let point = Point { row : 0 , column : 8 } ;
386
- let document = Document :: new ( "my_fun()" , None ) ;
385
+ let ( text , point) = point_from_cursor ( "my_fun()@" ) ;
386
+ let document = Document :: new ( text . as_str ( ) , None ) ;
387
387
let context = DocumentContext :: new ( & document, point, None ) ;
388
388
let completions = completions_from_call ( & context, None ) . unwrap ( ) ;
389
389
assert ! ( completions. is_none( ) ) ;
@@ -403,8 +403,8 @@ mod tests {
403
403
harp:: parse_eval ( "my_fun <- 1" , options. clone ( ) ) . unwrap ( ) ;
404
404
405
405
// Place cursor between `()`
406
- let point = Point { row : 0 , column : 7 } ;
407
- let document = Document :: new ( "my_fun()" , None ) ;
406
+ let ( text , point) = point_from_cursor ( "my_fun(@)" ) ;
407
+ let document = Document :: new ( text . as_str ( ) , None ) ;
408
408
let context = DocumentContext :: new ( & document, point, None ) ;
409
409
let completions = completions_from_call ( & context, None ) . unwrap ( ) . unwrap ( ) ;
410
410
assert_eq ! ( completions. len( ) , 0 ) ;
0 commit comments