File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -333,11 +333,17 @@ impl<'a> Formatter<'a> {
333333 }
334334
335335 fn format_newline_reserved_word ( & mut self , token : & Token < ' _ > , query : & mut String ) {
336- if !self . inline_block . is_active ( )
337- && self
338- . options
339- . max_inline_arguments
340- . is_none_or ( |limit| limit < self . indentation . span ( ) )
336+ // line comments force a newline
337+ let after_line_comment = self
338+ . previous_non_whitespace_token ( 1 )
339+ . is_some_and ( |t| t. kind == TokenKind :: LineComment ) ;
340+
341+ if after_line_comment
342+ || !self . inline_block . is_active ( )
343+ && self
344+ . options
345+ . max_inline_arguments
346+ . is_none_or ( |limit| limit < self . indentation . span ( ) )
341347 {
342348 // We inlined something to the top level let's increase the indentation now
343349 if let Some ( ( _, s) ) = self . indentation . previous_top_level_reserved ( ) {
@@ -346,6 +352,11 @@ impl<'a> Formatter<'a> {
346352 }
347353 }
348354
355+ // let's undo the line comment indentation
356+ if after_line_comment {
357+ self . trim_spaces_end ( query) ;
358+ }
359+
349360 self . add_new_line ( query) ;
350361 } else {
351362 self . trim_spaces_end ( query) ;
You can’t perform that action at this time.
0 commit comments