diff options
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs index b70c88ec2..4b5e37c11 100644 --- a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs | |||
@@ -431,7 +431,13 @@ fn best_action_for_target( | |||
431 | .find(|n| n.text_range().start() < anchor.text_range().start()) | 431 | .find(|n| n.text_range().start() < anchor.text_range().start()) |
432 | .or_else(|| Some(anchor)); | 432 | .or_else(|| Some(anchor)); |
433 | 433 | ||
434 | ImportAction::add_new_use(anchor, false) | 434 | let add_after_anchor = anchor |
435 | .clone() | ||
436 | .and_then(ast::Attr::cast) | ||
437 | .as_ref() | ||
438 | .map(ast::Attr::is_inner_attribute) | ||
439 | .unwrap_or(false); | ||
440 | ImportAction::add_new_use(anchor, add_after_anchor) | ||
435 | } | 441 | } |
436 | } | 442 | } |
437 | } | 443 | } |
@@ -962,4 +968,26 @@ mod foo { | |||
962 | ", | 968 | ", |
963 | ); | 969 | ); |
964 | } | 970 | } |
971 | |||
972 | #[test] | ||
973 | fn inserts_imports_after_inner_attributes() { | ||
974 | check_assist( | ||
975 | replace_qualified_name_with_use, | ||
976 | " | ||
977 | #![allow(dead_code)] | ||
978 | |||
979 | fn main() { | ||
980 | std::fmt::Debug<|> | ||
981 | } | ||
982 | ", | ||
983 | " | ||
984 | #![allow(dead_code)] | ||
985 | use std::fmt::Debug; | ||
986 | |||
987 | fn main() { | ||
988 | Debug<|> | ||
989 | } | ||
990 | ", | ||
991 | ); | ||
992 | } | ||
965 | } | 993 | } |