mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Avoid setting constrain min to infinity in Flex layout
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
f5752969ab
commit
36699dc095
@ -64,8 +64,16 @@ impl Element for Flex {
|
||||
if let Some(flex) = Self::child_flex(&child) {
|
||||
total_flex += flex;
|
||||
} else {
|
||||
let child_constraint =
|
||||
SizeConstraint::strict_along(cross_axis, constraint.max_along(cross_axis));
|
||||
let child_constraint = match self.axis {
|
||||
Axis::Horizontal => SizeConstraint::new(
|
||||
vec2f(0.0, constraint.min.y()),
|
||||
vec2f(INFINITY, constraint.max.y()),
|
||||
),
|
||||
Axis::Vertical => SizeConstraint::new(
|
||||
vec2f(constraint.min.x(), 0.0),
|
||||
vec2f(constraint.max.x(), INFINITY),
|
||||
),
|
||||
};
|
||||
let size = child.layout(child_constraint, ctx);
|
||||
fixed_space += size.along(self.axis);
|
||||
cross_axis_max = cross_axis_max.max(size.along(cross_axis));
|
||||
@ -85,11 +93,11 @@ impl Element for Flex {
|
||||
let child_max = space_per_flex * flex;
|
||||
let child_constraint = match self.axis {
|
||||
Axis::Horizontal => SizeConstraint::new(
|
||||
vec2f(0.0, constraint.max.y()),
|
||||
vec2f(0.0, constraint.min.y()),
|
||||
vec2f(child_max, constraint.max.y()),
|
||||
),
|
||||
Axis::Vertical => SizeConstraint::new(
|
||||
vec2f(constraint.max.x(), 0.0),
|
||||
vec2f(constraint.min.x(), 0.0),
|
||||
vec2f(constraint.max.x(), child_max),
|
||||
),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user