@@ -37,7 +37,6 @@ impl<'a, 'b> MemberChain<'a, 'b> {
3737 call_expression : & ' b AstNode < ' a , CallExpression < ' a > > ,
3838 f : & Formatter < ' _ , ' a > ,
3939 ) -> Self {
40- let parent = & call_expression. parent ;
4140 let mut chain_members = chain_members_iter ( call_expression, f) . collect :: < Vec < _ > > ( ) ;
4241 chain_members. reverse ( ) ;
4342
@@ -54,7 +53,7 @@ impl<'a, 'b> MemberChain<'a, 'b> {
5453
5554 // Here we check if the first element of Groups::groups can be moved inside the head.
5655 // If so, then we extract it and concatenate it together with the head.
57- member_chain. maybe_merge_with_first_group ( parent, f) ;
56+ member_chain. maybe_merge_with_first_group ( call_expression . parent , f) ;
5857
5958 member_chain
6059 }
@@ -93,14 +92,16 @@ impl<'a, 'b> MemberChain<'a, 'b> {
9392 if self . head . members ( ) . len ( ) == 1
9493 && let ChainMember :: Node ( node) = self . head . members ( ) [ 0 ]
9594 {
96- if let Expression :: Identifier ( identifier) = node. as_ref ( ) {
97- has_computed_property ||
98- is_factory ( & identifier. name ) ||
99- // If an identifier has a name that is shorter than the tab with, then we join it with the "head"
100- ( matches ! ( parent, AstNodes :: ExpressionStatement ( stmt) if !stmt. is_arrow_function_body( ) )
101- && has_short_name ( & identifier. name , f. options ( ) . indent_width . value ( ) ) )
102- } else {
103- matches ! ( node. as_ref( ) , Expression :: ThisExpression ( _) )
95+ match node. as_ref ( ) {
96+ Expression :: Identifier ( identifier) => {
97+ has_computed_property ||
98+ is_factory ( & identifier. name ) ||
99+ // If an identifier has a name that is shorter than the tab with, then we join it with the "head"
100+ ( matches ! ( parent. without_chain_expression( ) , AstNodes :: ExpressionStatement ( stmt) if !stmt. is_arrow_function_body( ) )
101+ && has_short_name ( & identifier. name , f. options ( ) . indent_width . value ( ) ) )
102+ }
103+ Expression :: ThisExpression ( _) => true ,
104+ _ => false ,
104105 }
105106 } else if let Some ( ChainMember :: StaticMember ( expression) ) = self . head . members ( ) . last ( ) {
106107 has_computed_property || is_factory ( & expression. property ( ) . name )
0 commit comments