aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_editor/src/assists/split_import.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/ra_editor/src/assists/split_import.rs b/crates/ra_editor/src/assists/split_import.rs
index 75f9e8dfb..e4015f07d 100644
--- a/crates/ra_editor/src/assists/split_import.rs
+++ b/crates/ra_editor/src/assists/split_import.rs
@@ -19,7 +19,10 @@ pub fn split_import(ctx: AssistCtx) -> Option<Assist> {
19 } 19 }
20 20
21 let l_curly = colon_colon.range().end(); 21 let l_curly = colon_colon.range().end();
22 let r_curly = top_path.syntax().range().end(); 22 let r_curly = match top_path.syntax().parent().and_then(ast::UseTree::cast) {
23 Some(tree) => tree.syntax().range().end(),
24 None => top_path.syntax().range().end(),
25 };
23 26
24 ctx.build("split import", |edit| { 27 ctx.build("split import", |edit| {
25 edit.insert(l_curly, "{"); 28 edit.insert(l_curly, "{");
@@ -41,4 +44,13 @@ mod tests {
41 "use crate::{<|>db::RootDatabase};", 44 "use crate::{<|>db::RootDatabase};",
42 ) 45 )
43 } 46 }
47
48 #[test]
49 fn split_import_works_with_trees() {
50 check_assist(
51 split_import,
52 "use algo:<|>:visitor::{Visitor, visit}",
53 "use algo::{<|>visitor::{Visitor, visit}}",
54 )
55 }
44} 56}