Skip to content

Commit 0e050fc

Browse files
Allow to configure the merge behavior
1 parent 1e458ef commit 0e050fc

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

crates/completion/src/completions/complete_magic.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! TODO kb move this into the complete_unqualified_path when starts to work properly
22
3-
use assists::utils::{insert_use, mod_path_to_ast, ImportScope, MergeBehaviour};
3+
use assists::utils::{insert_use, mod_path_to_ast, ImportScope};
44
use either::Either;
55
use hir::{db::HirDatabase, MacroDef, ModuleDef, Query};
66
use itertools::Itertools;
@@ -48,10 +48,7 @@ pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) ->
4848
);
4949
builder.replace(anchor.syntax().text_range(), correct_qualifier);
5050

51-
// TODO kb: assists already have the merge behaviour setting, need to unite both
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));
51+
let rewriter = insert_use(&import_scope, mod_path_to_ast(&mod_path), ctx.config.merge);
5552
let old_ast = rewriter.rewrite_root()?;
5653
algo::diff(&old_ast, &rewriter.rewrite(&old_ast)).into_text_edit(&mut builder);
5754

crates/completion/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
//! module, and we use to statically check that we only produce snippet
55
//! completions if we are allowed to.
66
7+
use assists::utils::MergeBehaviour;
8+
79
#[derive(Clone, Debug, PartialEq, Eq)]
810
pub struct CompletionConfig {
911
pub enable_postfix_completions: bool,
1012
pub add_call_parenthesis: bool,
1113
pub add_call_argument_snippets: bool,
1214
pub snippet_cap: Option<SnippetCap>,
15+
pub merge: Option<MergeBehaviour>,
1316
}
1417

1518
impl CompletionConfig {
@@ -30,6 +33,7 @@ impl Default for CompletionConfig {
3033
add_call_parenthesis: true,
3134
add_call_argument_snippets: true,
3235
snippet_cap: Some(SnippetCap { _private: () }),
36+
merge: Some(MergeBehaviour::Full),
3337
}
3438
}
3539
}

0 commit comments

Comments
 (0)