This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
crates/ide-completion/src/completions Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,13 @@ pub(crate) fn complete_postfix(
8484 )
8585 . add_to ( acc, ctx. db ) ;
8686
87+ postfix_snippet (
88+ "lete" ,
89+ "let Ok else {}" ,
90+ & format ! ( "let Ok($1) = {receiver_text} else {{\n $2\n }};\n $0" ) ,
91+ )
92+ . add_to ( acc, ctx. db ) ;
93+
8794 postfix_snippet (
8895 "while" ,
8996 "while let Ok {}" ,
@@ -99,6 +106,13 @@ pub(crate) fn complete_postfix(
99106 )
100107 . add_to ( acc, ctx. db ) ;
101108
109+ postfix_snippet (
110+ "lete" ,
111+ "let Some else {}" ,
112+ & format ! ( "let Some($1) = {receiver_text} else {{\n $2\n }};\n $0" ) ,
113+ )
114+ . add_to ( acc, ctx. db ) ;
115+
102116 postfix_snippet (
103117 "while" ,
104118 "while let Some {}" ,
@@ -469,6 +483,29 @@ fn main() {
469483 ) ;
470484 }
471485
486+ #[ test]
487+ fn option_letelse ( ) {
488+ check_edit (
489+ "lete" ,
490+ r#"
491+ //- minicore: option
492+ fn main() {
493+ let bar = Some(true);
494+ bar.$0
495+ }
496+ "# ,
497+ r#"
498+ fn main() {
499+ let bar = Some(true);
500+ let Some($1) = bar else {
501+ $2
502+ };
503+ $0
504+ }
505+ "# ,
506+ ) ;
507+ }
508+
472509 #[ test]
473510 fn result_match ( ) {
474511 check_edit (
You can’t perform that action at this time.
0 commit comments