Skip to content

Commit 1211a46

Browse files
committed
Unsquish parameter types in tooltips for macro-generated functions
1 parent f7f01dd commit 1211a46

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/ra_ide/src/display/function_signature.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,18 @@ impl From<&'_ ast::FnDef> for FunctionSignature {
207207
res.push(raw_param);
208208
}
209209

210-
res.extend(param_list.params().map(|param| param.syntax().text().to_string()));
210+
// macro-generated functions are missing whitespace
211+
fn fmt_param(param: ast::Param) -> String {
212+
let text = param.syntax().text().to_string();
213+
match text.find(':') {
214+
Some(pos) if 1 + pos < text.len() => {
215+
format!("{} {}", &text[0..1 + pos].trim(), &text[1 + pos..].trim())
216+
}
217+
_ => text,
218+
}
219+
}
220+
221+
res.extend(param_list.params().map(fmt_param));
211222
res_types.extend(param_list.params().map(|param| {
212223
let param_text = param.syntax().text().to_string();
213224
match param_text.split(':').nth(1).and_then(|it| it.get(1..)) {

0 commit comments

Comments
 (0)