From e55fc286fc60a32ff0b6d9e0dd56719e685af180 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 3 Mar 2020 20:46:59 +0100 Subject: Fix completion snippet for reexported functions Fixes #3356. --- crates/ra_ide/src/completion/complete_path.rs | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'crates/ra_ide/src/completion/complete_path.rs') diff --git a/crates/ra_ide/src/completion/complete_path.rs b/crates/ra_ide/src/completion/complete_path.rs index c626e90cc..1a9699466 100644 --- a/crates/ra_ide/src/completion/complete_path.rs +++ b/crates/ra_ide/src/completion/complete_path.rs @@ -784,4 +784,55 @@ mod tests { "### ); } + + #[test] + fn completes_reexported_items_under_correct_name() { + assert_debug_snapshot!( + do_reference_completion( + r" + fn foo() { + self::m::<|> + } + + mod m { + pub use super::p::wrong_fn as right_fn; + pub use super::p::WRONG_CONST as RIGHT_CONST; + pub use super::p::WrongType as RightType; + } + mod p { + fn wrong_fn() {} + const WRONG_CONST: u32 = 1; + struct WrongType {}; + } + " + ), + @r###" + [ + CompletionItem { + label: "RIGHT_CONST", + source_range: [57; 57), + delete: [57; 57), + insert: "RIGHT_CONST", + kind: Const, + }, + CompletionItem { + label: "RightType", + source_range: [57; 57), + delete: [57; 57), + insert: "RightType", + kind: Struct, + }, + CompletionItem { + label: "right_fn()", + source_range: [57; 57), + delete: [57; 57), + insert: "right_fn()$0", + kind: Function, + lookup: "right_fn", + detail: "fn wrong_fn()", + }, + ] + "### + ); + } } -- cgit v1.2.3