aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-06 09:50:33 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-06 09:50:33 +0000
commitcbac31cbdb2168b18fc6fb89f5cf069238cc6ccb (patch)
treeb31bc451478bff681e5297b5f00912791fcba6b0
parent3e42a158787955ff9f2e81be43479dbe8f2b1bb6 (diff)
parentbc3e732ec55fef42e9323fa25bd8ad5cfbba8d86 (diff)
Merge #443
443: split_import intention correctly works with use trees r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
-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}