aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-09 15:14:30 +0000
committerGitHub <[email protected]>2020-02-09 15:14:30 +0000
commit0db5525c445fb86a7fb7441267ffab2604d78a41 (patch)
tree5752029dcdf63aa7504a949979890a9a62d54e4f /crates/ra_assists
parenta836247de45d7187a3902c2f14034d2817dbfbc3 (diff)
parentfe141a8c10eb31c8793a6f6ecec522011d59a653 (diff)
Merge #3070
3070: Set auto-import target r=matklad a=matklad closes #3067 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/handlers/auto_import.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs
index d13332f37..e88c121eb 100644
--- a/crates/ra_assists/src/handlers/auto_import.rs
+++ b/crates/ra_assists/src/handlers/auto_import.rs
@@ -66,6 +66,7 @@ pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> {
66 let mut group = ctx.add_assist_group(format!("Import {}", name_to_import)); 66 let mut group = ctx.add_assist_group(format!("Import {}", name_to_import));
67 for import in proposed_imports { 67 for import in proposed_imports {
68 group.add_assist(AssistId("auto_import"), format!("Import `{}`", &import), |edit| { 68 group.add_assist(AssistId("auto_import"), format!("Import `{}`", &import), |edit| {
69 edit.target(path_to_import_syntax.text_range());
69 insert_use_statement( 70 insert_use_statement(
70 &position, 71 &position,
71 path_to_import_syntax, 72 path_to_import_syntax,
@@ -79,7 +80,7 @@ pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> {
79 80
80#[cfg(test)] 81#[cfg(test)]
81mod tests { 82mod tests {
82 use crate::helpers::{check_assist, check_assist_not_applicable}; 83 use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target};
83 84
84 use super::*; 85 use super::*;
85 86
@@ -250,4 +251,19 @@ mod tests {
250 ", 251 ",
251 ); 252 );
252 } 253 }
254
255 #[test]
256 fn auto_import_target() {
257 check_assist_target(
258 auto_import,
259 r"
260 struct AssistInfo {
261 group_label: Option<<|>GroupLabel>,
262 }
263
264 mod m { pub struct GroupLabel; }
265 ",
266 "GroupLabel",
267 )
268 }
253} 269}