File tree Expand file tree Collapse file tree 1 file changed +31
-4
lines changed
crates/completion/src/completions Expand file tree Collapse file tree 1 file changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ mod format_like;
5
5
use ide_db:: ty_filter:: TryEnum ;
6
6
use syntax:: {
7
7
ast:: { self , AstNode , AstToken } ,
8
- SyntaxKind :: BLOCK_EXPR ,
8
+ SyntaxKind :: { BLOCK_EXPR , EXPR_STMT } ,
9
9
TextRange , TextSize ,
10
10
} ;
11
11
use text_edit:: TextEdit ;
@@ -221,9 +221,8 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
221
221
)
222
222
. add_to ( acc) ;
223
223
224
- let parent_node = dot_receiver. syntax ( ) . parent ( ) . and_then ( |p| p. parent ( ) ) ;
225
- if let Some ( parent) = parent_node {
226
- if parent. kind ( ) == BLOCK_EXPR {
224
+ if let Some ( parent) = dot_receiver. syntax ( ) . parent ( ) . and_then ( |p| p. parent ( ) ) {
225
+ if matches ! ( parent. kind( ) , BLOCK_EXPR | EXPR_STMT ) {
227
226
postfix_snippet (
228
227
ctx,
229
228
cap,
@@ -389,6 +388,34 @@ fn main() {
389
388
)
390
389
}
391
390
391
+ #[ test]
392
+ fn let_middle_block ( ) {
393
+ check (
394
+ r#"
395
+ fn main() {
396
+ baz.l<|>
397
+ res
398
+ }
399
+ "# ,
400
+ expect ! [ [ r#"
401
+ sn box Box::new(expr)
402
+ sn call function(expr)
403
+ sn dbg dbg!(expr)
404
+ sn dbgr dbg!(&expr)
405
+ sn if if expr {}
406
+ sn let let
407
+ sn letm let mut
408
+ sn match match expr {}
409
+ sn not !expr
410
+ sn ok Ok(expr)
411
+ sn ref &expr
412
+ sn refm &mut expr
413
+ sn some Some(expr)
414
+ sn while while expr {}
415
+ "# ] ] ,
416
+ ) ;
417
+ }
418
+
392
419
#[ test]
393
420
fn option_iflet ( ) {
394
421
check_edit (
You can’t perform that action at this time.
0 commit comments