mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Optionally disable term search for autocompletion
This commit is contained in:
parent
0b838e3e23
commit
88964c0b6a
13 changed files with 163 additions and 41 deletions
|
@ -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")));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue