Skip to content

Commit 6afa5b0

Browse files
committed
better handling of spaces & newlines
1 parent 23ffda1 commit 6afa5b0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,18 @@ fn ref_of_param(ctx: &CompletionContext<'_>, arg: &str, ty: &hir::Type) -> &'sta
241241

242242
fn detail(db: &dyn HirDatabase, func: hir::Function, full_function_signature: bool) -> String {
243243
if full_function_signature {
244-
return format!("{}", func.display(db)).replace("\n", " ");
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;
245256
}
246257

247258
let mut ret_ty = func.ret_type(db);

0 commit comments

Comments
 (0)