Skip to content

Commit 0db5525

Browse files
bors[bot]matklad
andauthored
Merge #3070
3070: Set auto-import target r=matklad a=matklad closes #3067 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents a836247 + fe141a8 commit 0db5525

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

crates/ra_assists/src/handlers/auto_import.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> {
6666
let mut group = ctx.add_assist_group(format!("Import {}", name_to_import));
6767
for import in proposed_imports {
6868
group.add_assist(AssistId("auto_import"), format!("Import `{}`", &import), |edit| {
69+
edit.target(path_to_import_syntax.text_range());
6970
insert_use_statement(
7071
&position,
7172
path_to_import_syntax,
@@ -79,7 +80,7 @@ pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> {
7980

8081
#[cfg(test)]
8182
mod tests {
82-
use crate::helpers::{check_assist, check_assist_not_applicable};
83+
use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target};
8384

8485
use super::*;
8586

@@ -250,4 +251,19 @@ mod tests {
250251
",
251252
);
252253
}
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+
}
253269
}

0 commit comments

Comments
 (0)