Skip to content

Commit 10fae62

Browse files
committed
split detail function
1 parent 9f3d627 commit 10fae62

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

crates/ide-completion/src/render/function.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,14 @@ fn render(
9898
_ => (),
9999
}
100100

101+
let detail = if ctx.completion.config.full_function_signatures {
102+
detail_full(db, func)
103+
} else {
104+
detail(db, func)
105+
};
101106
item.set_documentation(ctx.docs(func))
102107
.set_deprecated(ctx.is_deprecated(func) || ctx.is_deprecated_assoc_item(func))
103-
.detail(detail(db, func, ctx.completion.config.full_function_signatures))
108+
.detail(detail)
104109
.lookup_by(name.unescaped().to_smol_str());
105110

106111
match ctx.completion.config.snippet_cap {
@@ -239,22 +244,7 @@ fn ref_of_param(ctx: &CompletionContext<'_>, arg: &str, ty: &hir::Type) -> &'sta
239244
""
240245
}
241246

242-
fn detail(db: &dyn HirDatabase, func: hir::Function, full_function_signature: bool) -> String {
243-
if full_function_signature {
244-
let signature = format!("{}", func.display(db));
245-
let mut singleline = String::with_capacity(signature.len());
246-
247-
for segment in signature.split_whitespace() {
248-
if !singleline.is_empty() {
249-
singleline.push(' ');
250-
}
251-
252-
singleline.push_str(segment);
253-
}
254-
255-
return singleline;
256-
}
257-
247+
fn detail(db: &dyn HirDatabase, func: hir::Function) -> String {
258248
let mut ret_ty = func.ret_type(db);
259249
let mut detail = String::new();
260250

@@ -278,6 +268,21 @@ fn detail(db: &dyn HirDatabase, func: hir::Function, full_function_signature: bo
278268
detail
279269
}
280270

271+
fn detail_full(db: &dyn HirDatabase, func: hir::Function) -> String {
272+
let signature = format!("{}", func.display(db));
273+
let mut detail = String::with_capacity(signature.len());
274+
275+
for segment in signature.split_whitespace() {
276+
if !detail.is_empty() {
277+
detail.push(' ');
278+
}
279+
280+
detail.push_str(segment);
281+
}
282+
283+
detail
284+
}
285+
281286
fn params_display(db: &dyn HirDatabase, func: hir::Function) -> String {
282287
if let Some(self_param) = func.self_param(db) {
283288
let assoc_fn_params = func.assoc_fn_params(db);

0 commit comments

Comments
 (0)