From bc3e732ec55fef42e9323fa25bd8ad5cfbba8d86 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 6 Jan 2019 12:48:33 +0300 Subject: split_import intention correctly works with use trees --- crates/ra_editor/src/assists/split_import.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'crates/ra_editor/src') 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 { } let l_curly = colon_colon.range().end(); - let r_curly = top_path.syntax().range().end(); + let r_curly = match top_path.syntax().parent().and_then(ast::UseTree::cast) { + Some(tree) => tree.syntax().range().end(), + None => top_path.syntax().range().end(), + }; ctx.build("split import", |edit| { edit.insert(l_curly, "{"); @@ -41,4 +44,13 @@ mod tests { "use crate::{<|>db::RootDatabase};", ) } + + #[test] + fn split_import_works_with_trees() { + check_assist( + split_import, + "use algo:<|>:visitor::{Visitor, visit}", + "use algo::{<|>visitor::{Visitor, visit}}", + ) + } } -- cgit v1.2.3