aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-05 16:24:32 +0000
committerGitHub <[email protected]>2021-03-05 16:24:32 +0000
commit2b55cce49ecb7b8ff5a3b7c917c469929ed643ab (patch)
tree6a467003f358fc2e06fcf8fc6f4593148dd6067e /crates/ide_assists/src
parent6c27c55041953327d341f4e7c705e8887fc4dd50 (diff)
parent769b3bca2809d17a00c789012b510cc7822fe1c7 (diff)
Merge #7880
7880: Honor snippet capability when using the extract function assist r=lnicola a=Arthamys This fixes issue #7793 Co-authored-by: san <[email protected]>
Diffstat (limited to 'crates/ide_assists/src')
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index 9f34cc725..8779d8bd1 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -112,7 +112,10 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option
112 112
113 let fn_def = format_function(ctx, module, &fun, old_indent, new_indent); 113 let fn_def = format_function(ctx, module, &fun, old_indent, new_indent);
114 let insert_offset = insert_after.text_range().end(); 114 let insert_offset = insert_after.text_range().end();
115 builder.insert(insert_offset, fn_def); 115 match ctx.config.snippet_cap {
116 Some(cap) => builder.insert_snippet(cap, insert_offset, fn_def),
117 None => builder.insert(insert_offset, fn_def),
118 }
116 }, 119 },
117 ) 120 )
118} 121}
@@ -1079,7 +1082,10 @@ fn format_function(
1079 let params = make_param_list(ctx, module, fun); 1082 let params = make_param_list(ctx, module, fun);
1080 let ret_ty = make_ret_ty(ctx, module, fun); 1083 let ret_ty = make_ret_ty(ctx, module, fun);
1081 let body = make_body(ctx, old_indent, new_indent, fun); 1084 let body = make_body(ctx, old_indent, new_indent, fun);
1082 format_to!(fn_def, "\n\n{}fn $0{}{}", new_indent, fun.name, params); 1085 match ctx.config.snippet_cap {
1086 Some(_) => format_to!(fn_def, "\n\n{}fn $0{}{}", new_indent, fun.name, params),
1087 None => format_to!(fn_def, "\n\n{}fn {}{}", new_indent, fun.name, params),
1088 }
1083 if let Some(ret_ty) = ret_ty { 1089 if let Some(ret_ty) = ret_ty {
1084 format_to!(fn_def, " {}", ret_ty); 1090 format_to!(fn_def, " {}", ret_ty);
1085 } 1091 }