Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/render/function.rs')
-rw-r--r--crates/ide-completion/src/render/function.rs39
1 files changed, 22 insertions, 17 deletions
diff --git a/crates/ide-completion/src/render/function.rs b/crates/ide-completion/src/render/function.rs
index dd7de72190..dfae715afe 100644
--- a/crates/ide-completion/src/render/function.rs
+++ b/crates/ide-completion/src/render/function.rs
@@ -98,9 +98,14 @@ fn render(
_ => (),
}
+ let detail = if ctx.completion.config.full_function_signatures {
+ detail_full(db, func)
+ } else {
+ detail(db, func)
+ };
item.set_documentation(ctx.docs(func))
.set_deprecated(ctx.is_deprecated(func) || ctx.is_deprecated_assoc_item(func))
- .detail(detail(db, func, ctx.completion.config.full_function_signatures))
+ .detail(detail)
.lookup_by(name.unescaped().to_smol_str());
match ctx.completion.config.snippet_cap {
@@ -239,22 +244,7 @@ fn ref_of_param(ctx: &CompletionContext<'_>, arg: &str, ty: &hir::Type) -> &'sta
""
}
-fn detail(db: &dyn HirDatabase, func: hir::Function, full_function_signature: bool) -> String {
- if full_function_signature {
- let signature = format!("{}", func.display(db));
- let mut singleline = String::with_capacity(signature.len());
-
- for segment in signature.split_whitespace() {
- if !singleline.is_empty() {
- singleline.push(' ');
- }
-
- singleline.push_str(segment);
- }
-
- return singleline;
- }
-
+fn detail(db: &dyn HirDatabase, func: hir::Function) -> String {
let mut ret_ty = func.ret_type(db);
let mut detail = String::new();
@@ -278,6 +268,21 @@ fn detail(db: &dyn HirDatabase, func: hir::Function, full_function_signature: bo
detail
}
+fn detail_full(db: &dyn HirDatabase, func: hir::Function) -> String {
+ let signature = format!("{}", func.display(db));
+ let mut detail = String::with_capacity(signature.len());
+
+ for segment in signature.split_whitespace() {
+ if !detail.is_empty() {
+ detail.push(' ');
+ }
+
+ detail.push_str(segment);
+ }
+
+ detail
+}
+
fn params_display(db: &dyn HirDatabase, func: hir::Function) -> String {
if let Some(self_param) = func.self_param(db) {
let assoc_fn_params = func.assoc_fn_params(db);