@@ -16,13 +16,14 @@ pub(crate) enum Step {
1616
1717#[ derive( Clone ) ]
1818pub ( crate ) struct BuildCtx {
19- pub config : Config ,
20- pub force_wide : bool ,
21- pub force_wide_success : bool ,
22- pub indentation : usize ,
23- pub pos_old : crate :: position:: Position ,
24- pub path : String ,
25- pub vertical : bool ,
19+ pub config : Config ,
20+ pub fitting_in_single_line_depth : usize ,
21+ pub force_wide : bool ,
22+ pub force_wide_success : bool ,
23+ pub indentation : usize ,
24+ pub pos_old : crate :: position:: Position ,
25+ pub path : String ,
26+ pub vertical : bool ,
2627}
2728
2829pub ( crate ) fn build (
@@ -262,6 +263,7 @@ fn format_wider(
262263 match element {
263264 rnix:: SyntaxElement :: Node ( node) => {
264265 let mut build_ctx_clone = build_ctx. clone ( ) ;
266+
265267 build_ctx_clone. vertical =
266268 !fits_in_single_line ( build_ctx, node. clone ( ) . into ( ) ) ;
267269
@@ -284,7 +286,17 @@ pub(crate) fn fits_in_single_line(
284286 ..build_ctx_old. clone ( )
285287 } ;
286288
287- build ( & mut build_ctx, element) . is_some ( )
289+ build_ctx. fitting_in_single_line_depth += 1 ;
290+
291+ if build_ctx. fitting_in_single_line_depth >= 2 {
292+ return true ;
293+ }
294+
295+ let fits = build ( & mut build_ctx, element) . is_some ( ) ;
296+
297+ build_ctx. fitting_in_single_line_depth -= 1 ;
298+
299+ fits
288300}
289301
290302pub ( crate ) fn make_isolated_token (
0 commit comments