diff options
author | Kirill Bulatov <[email protected]> | 2020-11-10 21:40:07 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-11-16 19:19:06 +0000 |
commit | 0e050fc3eba251f3debf964c7779c522e5639cd8 (patch) | |
tree | a56bfe84df95870072bd3ad9e6747c8ed813d64a /crates/completion/src/completions | |
parent | 1e458efe628215dfc07943f8dd39f66ac059d3de (diff) |
Allow to configure the merge behavior
Diffstat (limited to 'crates/completion/src/completions')
-rw-r--r-- | crates/completion/src/completions/complete_magic.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/crates/completion/src/completions/complete_magic.rs b/crates/completion/src/completions/complete_magic.rs index 4cf21e19d..58509fc5b 100644 --- a/crates/completion/src/completions/complete_magic.rs +++ b/crates/completion/src/completions/complete_magic.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! TODO kb move this into the complete_unqualified_path when starts to work properly | 1 | //! TODO kb move this into the complete_unqualified_path when starts to work properly |
2 | 2 | ||
3 | use assists::utils::{insert_use, mod_path_to_ast, ImportScope, MergeBehaviour}; | 3 | use assists::utils::{insert_use, mod_path_to_ast, ImportScope}; |
4 | use either::Either; | 4 | use either::Either; |
5 | use hir::{db::HirDatabase, MacroDef, ModuleDef, Query}; | 5 | use hir::{db::HirDatabase, MacroDef, ModuleDef, Query}; |
6 | use itertools::Itertools; | 6 | use itertools::Itertools; |
@@ -48,10 +48,7 @@ pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> | |||
48 | ); | 48 | ); |
49 | builder.replace(anchor.syntax().text_range(), correct_qualifier); | 49 | builder.replace(anchor.syntax().text_range(), correct_qualifier); |
50 | 50 | ||
51 | // TODO kb: assists already have the merge behaviour setting, need to unite both | 51 | let rewriter = insert_use(&import_scope, mod_path_to_ast(&mod_path), ctx.config.merge); |
52 | // also consider a settings toggle for this particular feature? | ||
53 | let rewriter = | ||
54 | insert_use(&import_scope, mod_path_to_ast(&mod_path), Some(MergeBehaviour::Full)); | ||
55 | let old_ast = rewriter.rewrite_root()?; | 52 | let old_ast = rewriter.rewrite_root()?; |
56 | algo::diff(&old_ast, &rewriter.rewrite(&old_ast)).into_text_edit(&mut builder); | 53 | algo::diff(&old_ast, &rewriter.rewrite(&old_ast)).into_text_edit(&mut builder); |
57 | 54 | ||