diff options
author | Aleksey Kladov <[email protected]> | 2019-01-06 09:48:33 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-06 09:48:33 +0000 |
commit | bc3e732ec55fef42e9323fa25bd8ad5cfbba8d86 (patch) | |
tree | b31bc451478bff681e5297b5f00912791fcba6b0 /crates/ra_editor/src/assists | |
parent | 3e42a158787955ff9f2e81be43479dbe8f2b1bb6 (diff) |
split_import intention correctly works with use trees
Diffstat (limited to 'crates/ra_editor/src/assists')
-rw-r--r-- | crates/ra_editor/src/assists/split_import.rs | 14 |
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 | } |