implement preview: use fluent more often

This commit is contained in:
dylwil3 2025-12-08 12:42:14 -06:00
parent 8ba316db88
commit 2a5d66bb13
1 changed files with 28 additions and 3 deletions

View File

@ -993,12 +993,37 @@ impl CallChainLayout {
} }
} }
// Observe that `call_like_count >= attributes_after_parentheses`
//
// Indeed, the latter accumulates only at an attribute expression
// with non-parenthesized, call-like value. After that, we
// immediately set `was_in_call_like` to `true`. Any execution path
// from that code point to the exit or to the next accumulation of
// `attribute_after_parentheses` passes through
//
// ```
// call_like_count += u32::from(was_in_call_like);
// ```
//
// and it does so before it could pass through
// `was_in_call_like = false`.
//
// This justifies the name `fluent_layout_more_often_enabled`
// used below.
if is_fluent_layout_more_often_enabled(context) {
if call_like_count + u32::from(first_attr_value_parenthesized) < 2 {
CallChainLayout::NonFluent
} else {
CallChainLayout::Fluent(AttributeState::CallsOrSubscriptsPreceding(call_like_count))
}
} else {
if attributes_after_parentheses + u32::from(first_attr_value_parenthesized) < 2 { if attributes_after_parentheses + u32::from(first_attr_value_parenthesized) < 2 {
CallChainLayout::NonFluent CallChainLayout::NonFluent
} else { } else {
CallChainLayout::Fluent(AttributeState::CallsOrSubscriptsPreceding(call_like_count)) CallChainLayout::Fluent(AttributeState::CallsOrSubscriptsPreceding(call_like_count))
} }
} }
}
/// Determine whether to actually apply fluent layout in attribute, call and subscript /// Determine whether to actually apply fluent layout in attribute, call and subscript
/// formatting /// formatting