@@ -123,39 +123,39 @@ fn has_argument_leading_comments(argument: &AstNode<Expression>, f: &Formatter<'
123123 let start = left_side. span ( ) . start ;
124124 let comments = f. comments ( ) . comments_before ( start) ;
125125
126- let is_line_comment_or_multi_line_comment = |comments : & [ Comment ] | {
126+ if f. comments ( ) . comments_before_iter ( start) . any ( |comment| {
127+ source_text. contains_newline ( comment. span )
128+ || source_text. is_end_of_line_comment ( comment)
129+ } ) {
130+ return true ;
131+ }
132+
133+ let is_own_line_comment_or_multi_line_comment = |comments : & [ Comment ] | {
127134 comments. iter ( ) . any ( |comment| {
128- comment . is_line ( )
135+ source_text . is_own_line_comment ( comment )
129136 || source_text. contains_newline ( comment. span )
130- || source_text. is_end_of_line_comment ( comment)
131137 } )
132138 } ;
133139
134- if is_line_comment_or_multi_line_comment ( comments) {
135- return true ;
136- }
137-
138140 // This check is based on
139141 // <https://github.com/prettier/prettier/blob/7584432401a47a26943dd7a9ca9a8e032ead7285/src/language-js/comments/handle-comments.js#L335-L349>
140142 if let ExpressionLeftSide :: Expression ( left_side) = left_side {
141143 let has_leading_own_line_comment = match left_side. as_ref ( ) {
142144 Expression :: ChainExpression ( chain) => {
143145 if let ChainElement :: StaticMemberExpression ( member) = & chain. expression {
144- is_line_comment_or_multi_line_comment (
145- f. comments ( ) . comments_in_range (
146- member. object . span ( ) . end ,
147- member. property . span . end ,
148- ) ,
149- )
146+ let comments = f
147+ . comments ( )
148+ . comments_in_range ( member. object . span ( ) . end , member. property . span . end ) ;
149+ is_own_line_comment_or_multi_line_comment ( comments)
150150 } else {
151151 false
152152 }
153153 }
154154 Expression :: StaticMemberExpression ( member) => {
155- is_line_comment_or_multi_line_comment (
156- f . comments ( )
157- . comments_in_range ( member. object . span ( ) . end , member. property . span . end ) ,
158- )
155+ let comments = f
156+ . comments ( )
157+ . comments_in_range ( member. object . span ( ) . end , member. property . span . end ) ;
158+ is_own_line_comment_or_multi_line_comment ( comments )
159159 }
160160 _ => false ,
161161 } ;
0 commit comments