diff --git a/crates/completion/src/completions/complete_magic.rs b/crates/completion/src/completions/complete_magic.rs index 4cf21e19df0..58509fc5bab 100644 --- a/crates/completion/src/completions/complete_magic.rs +++ b/crates/completion/src/completions/complete_magic.rs @@ -1,6 +1,6 @@ //! TODO kb move this into the complete_unqualified_path when starts to work properly -use assists::utils::{insert_use, mod_path_to_ast, ImportScope, MergeBehaviour}; +use assists::utils::{insert_use, mod_path_to_ast, ImportScope}; use either::Either; use hir::{db::HirDatabase, MacroDef, ModuleDef, Query}; use itertools::Itertools; @@ -48,10 +48,7 @@ pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> ); builder.replace(anchor.syntax().text_range(), correct_qualifier); - // TODO kb: assists already have the merge behaviour setting, need to unite both - // also consider a settings toggle for this particular feature? - let rewriter = - insert_use(&import_scope, mod_path_to_ast(&mod_path), Some(MergeBehaviour::Full)); + let rewriter = insert_use(&import_scope, mod_path_to_ast(&mod_path), ctx.config.merge); let old_ast = rewriter.rewrite_root()?; algo::diff(&old_ast, &rewriter.rewrite(&old_ast)).into_text_edit(&mut builder); diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index 71b49ace8bf..82874ff256a 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs @@ -4,12 +4,15 @@ //! module, and we use to statically check that we only produce snippet //! completions if we are allowed to. +use assists::utils::MergeBehaviour; + #[derive(Clone, Debug, PartialEq, Eq)] pub struct CompletionConfig { pub enable_postfix_completions: bool, pub add_call_parenthesis: bool, pub add_call_argument_snippets: bool, pub snippet_cap: Option, + pub merge: Option, } impl CompletionConfig { @@ -30,6 +33,7 @@ fn default() -> Self { add_call_parenthesis: true, add_call_argument_snippets: true, snippet_cap: Some(SnippetCap { _private: () }), + merge: Some(MergeBehaviour::Full), } } }