This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
crates/ide-completion/src Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -747,4 +747,16 @@ fn main() {
747
747
"# ,
748
748
) ;
749
749
}
750
+
751
+ #[ test]
752
+ fn no_postfix_completions_in_if_block_that_has_an_else ( ) {
753
+ check (
754
+ r#"
755
+ fn test() {
756
+ if true {}.$0 else {}
757
+ }
758
+ "# ,
759
+ expect ! [ [ r#""# ] ] ,
760
+ ) ;
761
+ }
750
762
}
Original file line number Diff line number Diff line change @@ -605,6 +605,26 @@ fn classify_name_ref(
605
605
} ,
606
606
_ => false ,
607
607
} ;
608
+
609
+ let reciever_is_part_of_indivisible_expression = match & receiver {
610
+ Some ( ast:: Expr :: IfExpr ( _) ) => {
611
+ let next_sibling = field. dot_token( ) . and_then( |token| {
612
+ let dot_token = original_file. covering_element( token. text_range( ) ) ;
613
+ let next_sibling = dot_token. as_token( ) . and_then( |t| t. next_token( ) ) . and_then( |t| next_non_trivia_sibling( t. into( ) ) ) ;
614
+ next_sibling
615
+ } ) ;
616
+ match next_sibling {
617
+ Some ( syntax:: NodeOrToken :: Node ( n) ) => n. first_child_or_token( ) . map( |t| t. kind( ) ) == Some ( SyntaxKind :: ELSE_KW ) ,
618
+ Some ( syntax:: NodeOrToken :: Token ( t) ) => t. kind( ) == SyntaxKind :: ELSE_KW ,
619
+ None => false
620
+ }
621
+ } ,
622
+ _ => false
623
+ } ;
624
+ if reciever_is_part_of_indivisible_expression {
625
+ return None ;
626
+ }
627
+
608
628
let kind = NameRefKind :: DotAccess ( DotAccess {
609
629
receiver_ty: receiver. as_ref( ) . and_then( |it| sema. type_of_expr( it) ) ,
610
630
kind: DotAccessKind :: Field { receiver_is_ambiguous_float_literal } ,
You can’t perform that action at this time.
0 commit comments