diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2023-11-08 08:15:03 +0200 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2023-11-08 08:15:03 +0200 |
| commit | d1d111d09edcab2c87bc59ea69989d708e6bfa2d (patch) | |
| tree | 4ebb37ca611538b9100069e4639e549822892e89 /crates/ide-completion/src/render/function.rs | |
| parent | 6eaf3f8bb2824f7cb4c9b8271ea3e59b008a663e (diff) | |
| download | rust-d1d111d09edcab2c87bc59ea69989d708e6bfa2d.tar.gz rust-d1d111d09edcab2c87bc59ea69989d708e6bfa2d.zip | |
Merge commit '3b7c7f97e4a7bb253a8d398ee4f8346f6cf2817b' into sync-from-ra
Diffstat (limited to 'crates/ide-completion/src/render/function.rs')
| -rw-r--r-- | crates/ide-completion/src/render/function.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/ide-completion/src/render/function.rs b/crates/ide-completion/src/render/function.rs index 8afce8db5ea..dfae715afe3 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)) + .detail(detail) .lookup_by(name.unescaped().to_smol_str()); match ctx.completion.config.snippet_cap { @@ -263,6 +268,21 @@ fn detail(db: &dyn HirDatabase, func: hir::Function) -> String { 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); |
