Merge #443
443: split_import intention correctly works with use trees r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
cbac31cbdb
@ -19,7 +19,10 @@ pub fn split_import(ctx: AssistCtx) -> Option<Assist> {
|
||||
}
|
||||
|
||||
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 @@ fn test_split_import() {
|
||||
"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}}",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user