Optionally disable term search for autocompletion

This commit is contained in:
Tavo Annus 2024-01-22 20:34:17 +02:00
parent 0b838e3e23
commit 88964c0b6a
13 changed files with 163 additions and 41 deletions

View file

@ -295,7 +295,12 @@ pub(crate) fn render_expr(
.unwrap_or_else(|| String::from("..."))
};
let label = expr.gen_source_code(&ctx.scope, &mut label_formatter);
let label = expr.gen_source_code(
&ctx.scope,
&mut label_formatter,
ctx.config.prefer_no_std,
ctx.config.prefer_prelude,
);
let source_range = match ctx.original_token.parent() {
Some(node) => match node.ancestors().find_map(|n| ast::Path::cast(n)) {
@ -307,7 +312,15 @@ pub(crate) fn render_expr(
let mut item = CompletionItem::new(CompletionItemKind::Snippet, source_range, label.clone());
let snippet = format!("{}$0", expr.gen_source_code(&ctx.scope, &mut snippet_formatter));
let snippet = format!(
"{}$0",
expr.gen_source_code(
&ctx.scope,
&mut snippet_formatter,
ctx.config.prefer_no_std,
ctx.config.prefer_prelude
)
);
let edit = TextEdit::replace(source_range, snippet);
item.snippet_edit(ctx.config.snippet_cap?, edit);
item.documentation(Documentation::new(String::from("Autogenerated expression by term search")));