@@ -13,7 +13,7 @@ use ide_db::{
1313} ;
1414use stdx:: never;
1515use syntax:: {
16- SyntaxKind :: { BLOCK_EXPR , EXPR_STMT , FOR_EXPR , IF_EXPR , LOOP_EXPR , STMT_LIST , WHILE_EXPR } ,
16+ SyntaxKind :: { EXPR_STMT , STMT_LIST } ,
1717 T , TextRange , TextSize ,
1818 ast:: { self , AstNode , AstToken } ,
1919 match_ast,
@@ -253,18 +253,15 @@ pub(crate) fn complete_postfix(
253253 }
254254 }
255255
256- let mut block_should_be_wrapped = true ;
257- if dot_receiver. syntax ( ) . kind ( ) == BLOCK_EXPR {
258- block_should_be_wrapped = false ;
259- if let Some ( parent) = dot_receiver. syntax ( ) . parent ( )
260- && matches ! ( parent. kind( ) , IF_EXPR | WHILE_EXPR | LOOP_EXPR | FOR_EXPR )
261- {
262- block_should_be_wrapped = true ;
263- }
256+ let block_should_be_wrapped = if let ast:: Expr :: BlockExpr ( block) = dot_receiver {
257+ block. modifier ( ) . is_some ( ) || !block. is_standalone ( )
258+ } else {
259+ true
264260 } ;
265261 {
266262 let ( open_brace, close_brace) =
267263 if block_should_be_wrapped { ( "{ " , " }" ) } else { ( "" , "" ) } ;
264+ // FIXME: Why add parentheses
268265 let ( open_paren, close_paren) = if is_in_cond { ( "(" , ")" ) } else { ( "" , "" ) } ;
269266 let unsafe_completion_string =
270267 format ! ( "{open_paren}unsafe {open_brace}{receiver_text}{close_brace}{close_paren}" ) ;
@@ -842,6 +839,20 @@ fn main() {
842839 & format ! ( "fn main() {{ let x = {kind} {{ if true {{1}} else {{2}} }} }}" ) ,
843840 ) ;
844841
842+ if kind == "const" {
843+ check_edit (
844+ kind,
845+ r#"fn main() { unsafe {1}.$0 }"# ,
846+ & format ! ( "fn main() {{ {kind} {{ unsafe {{1}} }} }}" ) ,
847+ ) ;
848+ } else {
849+ check_edit (
850+ kind,
851+ r#"fn main() { const {1}.$0 }"# ,
852+ & format ! ( "fn main() {{ {kind} {{ const {{1}} }} }}" ) ,
853+ ) ;
854+ }
855+
845856 // completion will not be triggered
846857 check_edit (
847858 kind,
0 commit comments