diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-09 08:52:09 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-09 08:52:09 +0000 |
commit | 3e8351fb0607f8711749b00d80f68bf25de01a76 (patch) | |
tree | 97388dafe71ececcbaf97249021b9c8d49786ccf /crates/ra_assists/src/split_import.rs | |
parent | 12e3b4c70b5ef23b2fdfc197296d483680e125f9 (diff) | |
parent | 4fdeb54bb5c7ba0704839a65996766d223c51fc1 (diff) |
Merge #768
768: Sort assists by the range of the affected element r=matklad a=robojumper
Closes #763.
https://github.com/rust-analyzer/rust-analyzer/blob/3be98f2ac93b278828e76eb813bdd8033f647b12/crates/ra_assists/src/lib.rs#L233-L236
This could be made more robust by a) adding a way to identify actions by things other than their label and b) allowing arbitrary actions to appear in the list as long as the tested actions are there in the correct order. Let me know if I should do any of that.
Co-authored-by: robojumper <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/split_import.rs')
-rw-r--r-- | crates/ra_assists/src/split_import.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_assists/src/split_import.rs b/crates/ra_assists/src/split_import.rs index fb69cef9c..051bc6fec 100644 --- a/crates/ra_assists/src/split_import.rs +++ b/crates/ra_assists/src/split_import.rs | |||
@@ -24,6 +24,7 @@ pub(crate) fn split_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | |||
24 | }; | 24 | }; |
25 | 25 | ||
26 | ctx.build("split import", |edit| { | 26 | ctx.build("split import", |edit| { |
27 | edit.target(colon_colon.range()); | ||
27 | edit.insert(l_curly, "{"); | 28 | edit.insert(l_curly, "{"); |
28 | edit.insert(r_curly, "}"); | 29 | edit.insert(r_curly, "}"); |
29 | edit.set_cursor(l_curly + TextUnit::of_str("{")); | 30 | edit.set_cursor(l_curly + TextUnit::of_str("{")); |
@@ -33,7 +34,7 @@ pub(crate) fn split_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | |||
33 | #[cfg(test)] | 34 | #[cfg(test)] |
34 | mod tests { | 35 | mod tests { |
35 | use super::*; | 36 | use super::*; |
36 | use crate::helpers::check_assist; | 37 | use crate::helpers::{check_assist, check_assist_target}; |
37 | 38 | ||
38 | #[test] | 39 | #[test] |
39 | fn test_split_import() { | 40 | fn test_split_import() { |
@@ -52,4 +53,9 @@ mod tests { | |||
52 | "use algo::{<|>visitor::{Visitor, visit}}", | 53 | "use algo::{<|>visitor::{Visitor, visit}}", |
53 | ) | 54 | ) |
54 | } | 55 | } |
56 | |||
57 | #[test] | ||
58 | fn split_import_target() { | ||
59 | check_assist_target(split_import, "use algo::<|>visitor::{Visitor, visit}", "::"); | ||
60 | } | ||
55 | } | 61 | } |