Merge pull request #21557 from A4-Tacks/let-postfix-in-cond

feat: fallback let postfix completions in condition
This commit is contained in:
Chayim Refael Friedman 2026-02-03 04:12:18 +00:00 committed by GitHub
commit 2afde4e089
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -151,6 +151,10 @@ pub(crate) fn complete_postfix(
.add_to(acc, ctx.db);
}
},
_ if is_in_cond => {
postfix_snippet("let", "let", &format!("let $1 = {receiver_text}"))
.add_to(acc, ctx.db);
}
_ if matches!(second_ancestor.kind(), STMT_LIST | EXPR_STMT) => {
postfix_snippet("let", "let", &format!("let $0 = {receiver_text};"))
.add_to(acc, ctx.db);
@ -744,6 +748,25 @@ fn main() {
);
}
#[test]
fn iflet_fallback_cond() {
check_edit(
"let",
r#"
fn main() {
let bar = 2;
if bar.$0
}
"#,
r#"
fn main() {
let bar = 2;
if let $1 = bar
}
"#,
);
}
#[test]
fn option_letelse() {
check_edit(