Skip to content

Commit 4db2b5f

Browse files
Bugfix in dimension.py: handling of zero sized dimensions.
1 parent 52cd964 commit 4db2b5f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/prompt_toolkit/layout/dimension.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ def zero(cls) -> Dimension:
9999
"""
100100
return cls.exact(amount=0)
101101

102-
def is_zero(self) -> bool:
103-
"True if this `Dimension` represents a zero size."
104-
return self.preferred == 0 or self.max == 0
105-
106102
def __repr__(self) -> str:
107103
fields = []
108104
if self.min_specified:
@@ -139,11 +135,11 @@ def max_layout_dimensions(dimensions: list[Dimension]) -> Dimension:
139135
# If all dimensions are size zero. Return zero.
140136
# (This is important for HSplit/VSplit, to report the right values to their
141137
# parent when all children are invisible.)
142-
if all(d.is_zero() for d in dimensions):
143-
return dimensions[0]
138+
if all(d.preferred == 0 and d.max == 0 for d in dimensions):
139+
return Dimension.zero()
144140

145141
# Ignore empty dimensions. (They should not reduce the size of others.)
146-
dimensions = [d for d in dimensions if not d.is_zero()]
142+
dimensions = [d for d in dimensions if d.preferred != 0 and d.max != 0]
147143

148144
if dimensions:
149145
# Take the highest minimum dimension.

0 commit comments

Comments
 (0)