aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
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}