Skip to content

Commit 769b3bc

Browse files
committed
Honor snippet capability in extract function assist
1 parent 4a9eec4 commit 769b3bc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

crates/ide_assists/src/handlers/extract_function.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option
112112

113113
let fn_def = format_function(ctx, module, &fun, old_indent, new_indent);
114114
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+
}
116119
},
117120
)
118121
}
@@ -1079,7 +1082,10 @@ fn format_function(
10791082
let params = make_param_list(ctx, module, fun);
10801083
let ret_ty = make_ret_ty(ctx, module, fun);
10811084
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+
}
10831089
if let Some(ret_ty) = ret_ty {
10841090
format_to!(fn_def, " {}", ret_ty);
10851091
}

0 commit comments

Comments
 (0)