@@ -4,8 +4,9 @@ use crate::utils::scss_closing_comments::{
44 ClosingCommentSpacing , owns_include_closing_comments, write_include_closing_comments,
55} ;
66use biome_css_syntax:: {
7- ScssExpression , ScssListExpression , ScssListExpressionElementList , ScssListExpressionFields ,
8- ScssModuleConfiguration , ScssParenthesizedExpression , is_in_scss_include_arguments,
7+ ScssExpression , ScssExpressionItemList , ScssListExpression , ScssListExpressionElement ,
8+ ScssListExpressionElementList , ScssListExpressionFields , ScssModuleConfiguration ,
9+ ScssParenthesizedExpression , ScssVariableDeclaration , is_in_scss_include_arguments,
910 is_scss_map_key, is_scss_map_outer_parenthesized_value_list,
1011 scss_include_keyword_argument_owner, single_expression_item, unwrap_single_expression_item,
1112} ;
@@ -71,6 +72,19 @@ impl<'a> ScssListLayout<'a> {
7172 return write ! ( f, [ group( & format_args![ elements. format( ) ] ) ] ) ;
7273 }
7374
75+ if is_compound_variable_list ( self . node , & elements) {
76+ // Print `$buttonConfig:
77+ // "save" 50px,
78+ // "cancel" 50px;`.
79+ return write ! (
80+ f,
81+ [
82+ group( & indent( & format_args![ soft_line_break( ) , elements. format( ) ] ) )
83+ . should_expand( true )
84+ ]
85+ ) ;
86+ }
87+
7488 write ! (
7589 f,
7690 [ group( & indent( & format_args![
@@ -233,6 +247,38 @@ fn is_include_keyword_list_value_expanded_by_comments(
233247 has_trailing_comment || has_keyword_closing_comments
234248}
235249
250+ /// Detects `$buttonConfig: "save" 50px, "cancel" 50px;`.
251+ fn is_compound_variable_list (
252+ node : & ScssListExpression ,
253+ elements : & ScssListExpressionElementList ,
254+ ) -> bool {
255+ is_scss_variable_value_list ( node) && elements. len ( ) > 1 && has_compound_list_element ( elements)
256+ }
257+
258+ /// Checks that the list is the value in `$buttonConfig: "save" 50px, "cancel" 50px;`.
259+ fn is_scss_variable_value_list ( node : & ScssListExpression ) -> bool {
260+ node. parent :: < ScssExpressionItemList > ( )
261+ . and_then ( |items| items. parent :: < ScssExpression > ( ) )
262+ . and_then ( |expression| expression. parent :: < ScssVariableDeclaration > ( ) )
263+ . is_some ( )
264+ }
265+
266+ /// Checks for list items like `"save" 50px`.
267+ fn has_compound_list_element ( elements : & ScssListExpressionElementList ) -> bool {
268+ elements
269+ . iter ( )
270+ . any ( |element| element. as_ref ( ) . is_ok_and ( is_compound_list_element) )
271+ }
272+
273+ /// Checks whether `"save" 50px` has multiple values.
274+ fn is_compound_list_element ( element : & ScssListExpressionElement ) -> bool {
275+ element. value ( ) . ok ( ) . is_some_and ( |value| {
276+ value
277+ . as_scss_expression ( )
278+ . is_some_and ( |expression| expression. items ( ) . len ( ) > 1 )
279+ } )
280+ }
281+
236282/// Detects the list in `@use "x" with ($family: (a, b))`.
237283fn is_module_configuration_parenthesized_list_value ( node : & ScssListExpression ) -> bool {
238284 let Some ( parenthesized) = node
0 commit comments