fix: Adding async keyword when await is present in generate_function assist

This commit is contained in:
vi_mi 2021-07-09 19:18:22 +05:30
parent 80f193e3f8
commit 57f119b5fa
2 changed files with 34 additions and 4 deletions

View file

@ -587,6 +587,7 @@ pub fn fn_(
params: ast::ParamList,
body: ast::BlockExpr,
ret_type: Option<ast::RetType>,
is_async: bool,
) -> ast::Fn {
let type_params =
if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() };
@ -596,9 +597,11 @@ pub fn fn_(
Some(it) => format!("{} ", it),
};
let async_literal = if is_async { "async " } else { "" };
ast_from_text(&format!(
"{}fn {}{}{} {}{}",
visibility, fn_name, type_params, params, ret_type, body
"{}{}fn {}{}{} {}{}",
visibility, async_literal, fn_name, type_params, params, ret_type, body
))
}