From 0e814a3b5f5c7d034b0249cfb4391d9fcb9d8e42 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Sun, 24 May 2020 16:47:35 +0200 Subject: fix textedit range returned for completion when left token is a keyword #4545 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- .../src/completion/complete_unqualified_path.rs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'crates/ra_ide/src/completion/complete_unqualified_path.rs') diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs index db791660a..417a92001 100644 --- a/crates/ra_ide/src/completion/complete_unqualified_path.rs +++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs @@ -297,6 +297,41 @@ mod tests { ); } + #[test] + fn completes_bindings_from_for_with_in_prefix() { + assert_debug_snapshot!( + do_reference_completion( + r" + fn test() { + for index in &[1, 2, 3] { + let t = in<|> + } + } + " + ), + @r###" + [ + CompletionItem { + label: "index", + source_range: 107..107, + delete: 107..107, + insert: "index", + kind: Binding, + }, + CompletionItem { + label: "test()", + source_range: 107..107, + delete: 107..107, + insert: "test()$0", + kind: Function, + lookup: "test", + detail: "fn test()", + }, + ] + "### + ); + } + #[test] fn completes_generic_params() { assert_debug_snapshot!( -- cgit v1.2.3 From 846cefa4917dc68a85b7b307be5d1890b83e1e2d Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Wed, 27 May 2020 15:15:19 +0200 Subject: fix textedit range returned for completion when left token is a keyword Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_ide/src/completion/complete_unqualified_path.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/ra_ide/src/completion/complete_unqualified_path.rs') diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs index 417a92001..68032c37e 100644 --- a/crates/ra_ide/src/completion/complete_unqualified_path.rs +++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs @@ -299,6 +299,7 @@ mod tests { #[test] fn completes_bindings_from_for_with_in_prefix() { + mark::check!(completes_bindings_from_for_with_in_prefix); assert_debug_snapshot!( do_reference_completion( r" -- cgit v1.2.3