mirror of https://github.com/astral-sh/ruff
implement preview: use fluent more often
This commit is contained in:
parent
8ba316db88
commit
2a5d66bb13
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue