@@ -2,7 +2,7 @@ use crate::CssFormatter;
22use crate :: comments:: CssComments ;
33use crate :: prelude:: * ;
44use biome_css_syntax:: { CssGenericDelimiter , CssGenericProperty , CssLanguage , CssSyntaxKind } ;
5- use biome_formatter:: { CstFormatContext , write} ;
5+ use biome_formatter:: { CstFormatContext , format_args , write} ;
66use biome_formatter:: { FormatOptions , FormatResult } ;
77use biome_rowan:: { AstNode , AstNodeList , TextSize } ;
88use biome_string_case:: StrLikeExtension ;
@@ -112,7 +112,13 @@ where
112112 write ! ( f, [ group( & indent( & content) ) ] )
113113 }
114114 ValueListLayout :: Fill => {
115- write ! ( f, [ group( & indent( & values) ) ] )
115+ let with_line_break = format_with ( |f| {
116+ if should_preceded_by_softline ( node) {
117+ write ! ( f, [ soft_line_break( ) ] ) ?;
118+ }
119+ Ok ( ( ) )
120+ } ) ;
121+ write ! ( f, [ indent( & group( & format_args![ with_line_break, & values] ) ) ] )
116122 }
117123 ValueListLayout :: SingleValue => {
118124 write ! ( f, [ values] )
@@ -209,6 +215,15 @@ pub(crate) enum ValueListLayout {
209215 OneGroupPerLine ,
210216}
211217
218+ fn should_preceded_by_softline < N , I > ( node : & N ) -> bool
219+ where
220+ N : AstNodeList < Language = CssLanguage , Node = I > + AstNode < Language = CssLanguage > ,
221+ I : AstNode < Language = CssLanguage > + IntoFormat < CssFormatContext > ,
222+ {
223+ node. iter ( )
224+ . any ( |element| CssGenericDelimiter :: can_cast ( element. syntax ( ) . kind ( ) ) )
225+ }
226+
212227/// Returns the layout to use when printing the provided CssComponentValueList.
213228/// Until the parser supports comma-separated lists, this will always return
214229/// [ValueListLayout::Fill], since all space-separated lists are intentionally
0 commit comments