Merge pull request #21557 from A4-Tacks/let-postfix-in-cond
feat: fallback let postfix completions in condition
This commit is contained in:
commit
2afde4e089
1 changed files with 23 additions and 0 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue