diff options
author | Daiki Ihara <[email protected]> | 2021-06-21 14:47:39 +0100 |
---|---|---|
committer | Daiki Ihara <[email protected]> | 2021-06-21 14:47:39 +0100 |
commit | 873aa904f253abc60ebb5b7f8ce4412f3c984604 (patch) | |
tree | a109040c73f6cdf3a830323f47a3ae067cb19b92 /crates | |
parent | 7a04f72220736025820adb7ac5c9b2ce41e4a4c2 (diff) |
Fix var name
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide_assists/src/handlers/extract_function.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs index 6a9a84da0..870d4f665 100644 --- a/crates/ide_assists/src/handlers/extract_function.rs +++ b/crates/ide_assists/src/handlers/extract_function.rs | |||
@@ -109,15 +109,15 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
109 | 109 | ||
110 | let new_indent = IndentLevel::from_node(&insert_after); | 110 | let new_indent = IndentLevel::from_node(&insert_after); |
111 | let old_indent = fun.body.indent_level(); | 111 | let old_indent = fun.body.indent_level(); |
112 | let is_body_contains_await = body_contains_await(&fun.body); | 112 | let body_contains_await = body_contains_await(&fun.body); |
113 | 113 | ||
114 | builder.replace( | 114 | builder.replace( |
115 | target_range, | 115 | target_range, |
116 | format_replacement(ctx, &fun, old_indent, is_body_contains_await), | 116 | format_replacement(ctx, &fun, old_indent, body_contains_await), |
117 | ); | 117 | ); |
118 | 118 | ||
119 | let fn_def = | 119 | let fn_def = |
120 | format_function(ctx, module, &fun, old_indent, new_indent, is_body_contains_await); | 120 | format_function(ctx, module, &fun, old_indent, new_indent, body_contains_await); |
121 | let insert_offset = insert_after.text_range().end(); | 121 | let insert_offset = insert_after.text_range().end(); |
122 | match ctx.config.snippet_cap { | 122 | match ctx.config.snippet_cap { |
123 | Some(cap) => builder.insert_snippet(cap, insert_offset, fn_def), | 123 | Some(cap) => builder.insert_snippet(cap, insert_offset, fn_def), |
@@ -963,7 +963,7 @@ fn format_replacement( | |||
963 | ctx: &AssistContext, | 963 | ctx: &AssistContext, |
964 | fun: &Function, | 964 | fun: &Function, |
965 | indent: IndentLevel, | 965 | indent: IndentLevel, |
966 | is_body_contains_await: bool, | 966 | body_contains_await: bool, |
967 | ) -> String { | 967 | ) -> String { |
968 | let ret_ty = fun.return_type(ctx); | 968 | let ret_ty = fun.return_type(ctx); |
969 | 969 | ||
@@ -1004,7 +1004,7 @@ fn format_replacement( | |||
1004 | } | 1004 | } |
1005 | } | 1005 | } |
1006 | format_to!(buf, "{}", expr); | 1006 | format_to!(buf, "{}", expr); |
1007 | if is_body_contains_await { | 1007 | if body_contains_await { |
1008 | buf.push_str(".await"); | 1008 | buf.push_str(".await"); |
1009 | } | 1009 | } |
1010 | if fun.ret_ty.is_unit() | 1010 | if fun.ret_ty.is_unit() |
@@ -1135,13 +1135,13 @@ fn format_function( | |||
1135 | fun: &Function, | 1135 | fun: &Function, |
1136 | old_indent: IndentLevel, | 1136 | old_indent: IndentLevel, |
1137 | new_indent: IndentLevel, | 1137 | new_indent: IndentLevel, |
1138 | is_body_contains_await: bool, | 1138 | body_contains_await: bool, |
1139 | ) -> String { | 1139 | ) -> String { |
1140 | let mut fn_def = String::new(); | 1140 | let mut fn_def = String::new(); |
1141 | let params = make_param_list(ctx, module, fun); | 1141 | let params = make_param_list(ctx, module, fun); |
1142 | let ret_ty = make_ret_ty(ctx, module, fun); | 1142 | let ret_ty = make_ret_ty(ctx, module, fun); |
1143 | let body = make_body(ctx, old_indent, new_indent, fun); | 1143 | let body = make_body(ctx, old_indent, new_indent, fun); |
1144 | let async_kw = if is_body_contains_await { "async " } else { "" }; | 1144 | let async_kw = if body_contains_await { "async " } else { "" }; |
1145 | match ctx.config.snippet_cap { | 1145 | match ctx.config.snippet_cap { |
1146 | Some(_) => format_to!(fn_def, "\n\n{}{}fn $0{}{}", new_indent, async_kw, fun.name, params), | 1146 | Some(_) => format_to!(fn_def, "\n\n{}{}fn $0{}{}", new_indent, async_kw, fun.name, params), |
1147 | None => format_to!(fn_def, "\n\n{}{}fn {}{}", new_indent, async_kw, fun.name, params), | 1147 | None => format_to!(fn_def, "\n\n{}{}fn {}{}", new_indent, async_kw, fun.name, params), |