@@ -1238,7 +1238,9 @@ fn process_container(
12381238) {
12391239 let node_kind = GDScriptNodeKind :: get_kind_from_ast_node ( node) ;
12401240 let child_count = node. child_count ( ) ;
1241- if child_count < 3 {
1241+ // The style guide requires enum members to be written vertically, even
1242+ // when the list would fit on one line. Empty enums are the only exception.
1243+ if child_count < 3 && node_kind != GDScriptNodeKind :: EnumeratorList {
12421244 if let Some ( open) = node. child ( 0 ) {
12431245 process_node ( input, open, render_elements) ;
12441246 }
@@ -1371,6 +1373,7 @@ fn process_container(
13711373 // for a forced line break.
13721374 const MIN_CHILD_COUNT_BEYOND_SINGLE_ELEMENT : usize = 4 ;
13731375 let contains_more_than_one_element = child_count >= MIN_CHILD_COUNT_BEYOND_SINGLE_ELEMENT ;
1376+ let is_non_empty_enum = node_kind == GDScriptNodeKind :: EnumeratorList ;
13741377 // A single lambda in a collection will cause a syntax error unless we wrap
13751378 // it in parentheses or insert a trailing comma on the last line
13761379 let mut is_array_with_single_lambda = false ;
@@ -1395,12 +1398,20 @@ fn process_container(
13951398 render_elements. push ( RenderElement :: TextStatic ( "," ) ) ;
13961399 }
13971400
1398- if contains_more_than_one_element && let Some ( open) = node. child ( 0 ) {
1401+ // A single enum member also needs a trailing comma in its mandatory
1402+ // multiline layout.
1403+ if is_non_empty_enum && !contains_more_than_one_element && !trailing_comma_handled {
1404+ render_elements. push ( RenderElement :: TextStatic ( "," ) ) ;
1405+ }
1406+
1407+ if ( contains_more_than_one_element || is_non_empty_enum)
1408+ && let Some ( open) = node. child ( 0 )
1409+ {
13991410 let close_byte = node
14001411 . child ( ( child_count - 1 ) as u32 )
14011412 . expect ( "container node has close delimiter" )
14021413 . start_byte ( ) ;
1403- if has_newline ( input. source , open. end_byte ( ) , close_byte) {
1414+ if is_non_empty_enum || has_newline ( input. source , open. end_byte ( ) , close_byte) {
14041415 render_elements. push ( RenderElement :: ForceBreakingParent ) ;
14051416 }
14061417 }
0 commit comments