Skip to content

Commit 5bf0183

Browse files
committed
Terminal Use point_from_cursor() in these tests
1 parent e8ff62a commit 5bf0183

File tree

1 file changed

+15
-15
lines changed
  • crates/ark/src/lsp/completions/sources/composite

1 file changed

+15
-15
lines changed

crates/ark/src/lsp/completions/sources/composite/call.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ fn completions_from_workspace_arguments(
302302
#[cfg(test)]
303303
mod tests {
304304
use harp::eval::RParseEvalOptions;
305-
use tree_sitter::Point;
306305

306+
use crate::fixtures::point_from_cursor;
307307
use crate::lsp::completions::sources::composite::call::completions_from_call;
308308
use crate::lsp::document_context::DocumentContext;
309309
use crate::lsp::documents::Document;
@@ -313,8 +313,8 @@ mod tests {
313313
fn test_completions_after_user_types_part_of_an_argument_name() {
314314
r_task(|| {
315315
// 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);
318318
let context = DocumentContext::new(&document, point, None);
319319
let completions = completions_from_call(&context, None).unwrap().unwrap();
320320

@@ -324,8 +324,8 @@ mod tests {
324324
assert_eq!(completions.get(1).unwrap().label, "table = ");
325325

326326
// 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);
329329
let context = DocumentContext::new(&document, point, None);
330330
let completions = completions_from_call(&context, None).unwrap().unwrap();
331331

@@ -342,8 +342,8 @@ mod tests {
342342
// Can't find the function
343343
r_task(|| {
344344
// 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);
347347
let context = DocumentContext::new(&document, point, None);
348348
let completions = completions_from_call(&context, None).unwrap();
349349
assert!(completions.is_none());
@@ -360,8 +360,8 @@ mod tests {
360360
harp::parse_eval("my_fun <- function(y, x) x + y", options.clone()).unwrap();
361361

362362
// 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);
365365
let context = DocumentContext::new(&document, point, None);
366366
let completions = completions_from_call(&context, None).unwrap().unwrap();
367367

@@ -375,15 +375,15 @@ mod tests {
375375
assert_eq!(completion.label, "x = ");
376376

377377
// 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);
380380
let context = DocumentContext::new(&document, point, None);
381381
let completions = completions_from_call(&context, None).unwrap();
382382
assert!(completions.is_none());
383383

384384
// 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);
387387
let context = DocumentContext::new(&document, point, None);
388388
let completions = completions_from_call(&context, None).unwrap();
389389
assert!(completions.is_none());
@@ -403,8 +403,8 @@ mod tests {
403403
harp::parse_eval("my_fun <- 1", options.clone()).unwrap();
404404

405405
// 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);
408408
let context = DocumentContext::new(&document, point, None);
409409
let completions = completions_from_call(&context, None).unwrap().unwrap();
410410
assert_eq!(completions.len(), 0);

0 commit comments

Comments
 (0)