From 1211a46826ee8a08683e4cfe151649efd6fd90fa Mon Sep 17 00:00:00 2001 From: Aaron Loucks Date: Sun, 31 May 2020 18:58:54 -0400 Subject: Unsquish parameter types in tooltips for macro-generated functions --- crates/ra_ide/src/display/function_signature.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index 9572debd8..b081ecaad 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs @@ -207,7 +207,18 @@ impl From<&'_ ast::FnDef> for FunctionSignature { res.push(raw_param); } - res.extend(param_list.params().map(|param| param.syntax().text().to_string())); + // macro-generated functions are missing whitespace + fn fmt_param(param: ast::Param) -> String { + let text = param.syntax().text().to_string(); + match text.find(':') { + Some(pos) if 1 + pos < text.len() => { + format!("{} {}", &text[0..1 + pos].trim(), &text[1 + pos..].trim()) + } + _ => text, + } + } + + res.extend(param_list.params().map(fmt_param)); res_types.extend(param_list.params().map(|param| { let param_text = param.syntax().text().to_string(); match param_text.split(':').nth(1).and_then(|it| it.get(1..)) { -- cgit v1.2.3