aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-27 18:55:05 +0000
committerGitHub <[email protected]>2020-03-27 18:55:05 +0000
commita1fea0d34ee8f3436aefd87d4c133a7ff50ffbb0 (patch)
tree9afc05a20e5e51f757317a71906dc45a97861415 /crates/ra_assists/src
parent75f6ab208a2b3e5fea9e8b6362df3fad7308a0d5 (diff)
parentf016d8b900792c8ae4fce268920edea3035b6559 (diff)
Merge #3745
3745: Fix merge-imports assist for wildcard imports r=matklad a=piotr-szpetkowski Refs #3728 Besides the case mentioned in issue merging two diff-prefix wildcard uses will now work as well e.g. ```rust use std::cell::*; use std::str::*; ``` will translate into: ```rust use std::{cell::*, str::*} ``` I'd also like to explore usage of the `merge-imports` for same-prefix uses to simplify redundancy, but it seems like an idea for another issue and I'm not sure if it's something that this assist should do e.g.: ```rust use std::cell::Cell; use std::cell::*; ``` into: ```rust use std::cell::*; ``` Co-authored-by: Piotr Szpetkowski <[email protected]>
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/handlers/merge_imports.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs
index 9c57d1e30..5d4b74e56 100644
--- a/crates/ra_assists/src/handlers/merge_imports.rs
+++ b/crates/ra_assists/src/handlers/merge_imports.rs
@@ -171,6 +171,34 @@ use std::{fmt::<|>{Display, Debug}};
171 } 171 }
172 172
173 #[test] 173 #[test]
174 fn test_merge_single_wildcard_diff_prefixes() {
175 check_assist(
176 merge_imports,
177 r"
178use std<|>::cell::*;
179use std::str;
180",
181 r"
182use std<|>::{cell::*, str};
183",
184 )
185 }
186
187 #[test]
188 fn test_merge_both_wildcard_diff_prefixes() {
189 check_assist(
190 merge_imports,
191 r"
192use std<|>::cell::*;
193use std::str::*;
194",
195 r"
196use std<|>::{cell::*, str::*};
197",
198 )
199 }
200
201 #[test]
174 fn removes_just_enough_whitespace() { 202 fn removes_just_enough_whitespace() {
175 check_assist( 203 check_assist(
176 merge_imports, 204 merge_imports,