diff options
author | Lukas Wirth <[email protected]> | 2021-06-18 22:11:56 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-06-18 22:11:56 +0100 |
commit | 2ee090faaf69474a2baadf0494ef3c6ed4fdbcbc (patch) | |
tree | e67e1f3404fefb2dc3999b94f86bc9cbcca33dd1 /crates/ide_assists | |
parent | 84507a0b9c2e8f6e632ad9ec649cd1f21a7e0887 (diff) |
Allow to disable import insertion on single path glob imports
Diffstat (limited to 'crates/ide_assists')
4 files changed, 4 insertions, 3 deletions
diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index d4748ef3a..6c7348178 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs | |||
@@ -104,7 +104,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
104 | ImportScope::File(it) => ImportScope::File(builder.make_mut(it)), | 104 | ImportScope::File(it) => ImportScope::File(builder.make_mut(it)), |
105 | ImportScope::Module(it) => ImportScope::Module(builder.make_mut(it)), | 105 | ImportScope::Module(it) => ImportScope::Module(builder.make_mut(it)), |
106 | }; | 106 | }; |
107 | insert_use(&scope, mod_path_to_ast(&import.import_path), ctx.config.insert_use); | 107 | insert_use(&scope, mod_path_to_ast(&import.import_path), &ctx.config.insert_use); |
108 | }, | 108 | }, |
109 | ); | 109 | ); |
110 | } | 110 | } |
diff --git a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs index d3ff7b65c..da6df9106 100644 --- a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -235,7 +235,7 @@ fn apply_references( | |||
235 | import: Option<(ImportScope, hir::ModPath)>, | 235 | import: Option<(ImportScope, hir::ModPath)>, |
236 | ) { | 236 | ) { |
237 | if let Some((scope, path)) = import { | 237 | if let Some((scope, path)) = import { |
238 | insert_use(&scope, mod_path_to_ast(&path), insert_use_cfg); | 238 | insert_use(&scope, mod_path_to_ast(&path), &insert_use_cfg); |
239 | } | 239 | } |
240 | // deep clone to prevent cycle | 240 | // deep clone to prevent cycle |
241 | let path = make::path_from_segments(iter::once(segment.clone_subtree()), false); | 241 | let path = make::path_from_segments(iter::once(segment.clone_subtree()), false); |
diff --git a/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs index 39f5eb4ff..26019c793 100644 --- a/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs | |||
@@ -43,7 +43,7 @@ pub(crate) fn replace_qualified_name_with_use( | |||
43 | let syntax = builder.make_syntax_mut(syntax.clone()); | 43 | let syntax = builder.make_syntax_mut(syntax.clone()); |
44 | if let Some(ref import_scope) = ImportScope::from(syntax.clone()) { | 44 | if let Some(ref import_scope) = ImportScope::from(syntax.clone()) { |
45 | shorten_paths(&syntax, &path.clone_for_update()); | 45 | shorten_paths(&syntax, &path.clone_for_update()); |
46 | insert_use(import_scope, path, ctx.config.insert_use); | 46 | insert_use(import_scope, path, &ctx.config.insert_use); |
47 | } | 47 | } |
48 | }, | 48 | }, |
49 | ) | 49 | ) |
diff --git a/crates/ide_assists/src/tests.rs b/crates/ide_assists/src/tests.rs index 29bd4a563..b6f224b21 100644 --- a/crates/ide_assists/src/tests.rs +++ b/crates/ide_assists/src/tests.rs | |||
@@ -28,6 +28,7 @@ pub(crate) const TEST_CONFIG: AssistConfig = AssistConfig { | |||
28 | prefix_kind: hir::PrefixKind::Plain, | 28 | prefix_kind: hir::PrefixKind::Plain, |
29 | enforce_granularity: true, | 29 | enforce_granularity: true, |
30 | group: true, | 30 | group: true, |
31 | skip_glob_imports: true, | ||
31 | }, | 32 | }, |
32 | }; | 33 | }; |
33 | 34 | ||