diff options
Diffstat (limited to 'crates/ra_assists/src/assists/split_import.rs')
-rw-r--r-- | crates/ra_assists/src/assists/split_import.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/split_import.rs b/crates/ra_assists/src/assists/split_import.rs index 8d8a28987..5f8d6b0be 100644 --- a/crates/ra_assists/src/assists/split_import.rs +++ b/crates/ra_assists/src/assists/split_import.rs | |||
@@ -16,7 +16,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
16 | // ``` | 16 | // ``` |
17 | // use std::{collections::HashMap}; | 17 | // use std::{collections::HashMap}; |
18 | // ``` | 18 | // ``` |
19 | pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 19 | pub(crate) fn split_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
20 | let colon_colon = ctx.find_token_at_offset(T![::])?; | 20 | let colon_colon = ctx.find_token_at_offset(T![::])?; |
21 | let path = ast::Path::cast(colon_colon.parent())?; | 21 | let path = ast::Path::cast(colon_colon.parent())?; |
22 | let top_path = successors(Some(path), |it| it.parent_path()).last()?; | 22 | let top_path = successors(Some(path), |it| it.parent_path()).last()?; |
@@ -32,14 +32,12 @@ pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assis | |||
32 | None => top_path.syntax().text_range().end(), | 32 | None => top_path.syntax().text_range().end(), |
33 | }; | 33 | }; |
34 | 34 | ||
35 | ctx.add_action(AssistId("split_import"), "split import", |edit| { | 35 | ctx.add_assist(AssistId("split_import"), "split import", |edit| { |
36 | edit.target(colon_colon.text_range()); | 36 | edit.target(colon_colon.text_range()); |
37 | edit.insert(l_curly, "{"); | 37 | edit.insert(l_curly, "{"); |
38 | edit.insert(r_curly, "}"); | 38 | edit.insert(r_curly, "}"); |
39 | edit.set_cursor(l_curly + TextUnit::of_str("{")); | 39 | edit.set_cursor(l_curly + TextUnit::of_str("{")); |
40 | }); | 40 | }) |
41 | |||
42 | ctx.build() | ||
43 | } | 41 | } |
44 | 42 | ||
45 | #[cfg(test)] | 43 | #[cfg(test)] |