Skip to content

Commit 775c691

Browse files
committed
add let and letm postfix to turn expressions into variables
Signed-off-by: Benjamin Coenen <[email protected]>
1 parent cadf0e9 commit 775c691

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/completion/src/completions/postfix.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
220220
)
221221
.add_to(acc);
222222

223+
postfix_snippet(ctx, cap, &dot_receiver, "let", "let", &format!("let $0 = {};", receiver_text))
224+
.add_to(acc);
225+
postfix_snippet(
226+
ctx,
227+
cap,
228+
&dot_receiver,
229+
"letm",
230+
"let mut",
231+
&format!("let mut $0 = {};", receiver_text),
232+
)
233+
.add_to(acc);
234+
223235
if let ast::Expr::Literal(literal) = dot_receiver.clone() {
224236
if let Some(literal_text) = ast::String::cast(literal.token()) {
225237
add_format_like_completions(acc, ctx, &dot_receiver, cap, &literal_text);
@@ -296,6 +308,8 @@ fn main() {
296308
sn dbg dbg!(expr)
297309
sn dbgr dbg!(&expr)
298310
sn if if expr {}
311+
sn let let
312+
sn letm let mut
299313
sn match match expr {}
300314
sn not !expr
301315
sn ok Ok(expr)
@@ -321,6 +335,8 @@ fn main() {
321335
sn call function(expr)
322336
sn dbg dbg!(expr)
323337
sn dbgr dbg!(&expr)
338+
sn let let
339+
sn letm let mut
324340
sn match match expr {}
325341
sn ok Ok(expr)
326342
sn ref &expr

0 commit comments

Comments
 (0)