Merge branch 'main' into expand-tree-expand-messages

This commit is contained in:
Dave Pearson
2023-05-10 10:12:58 +01:00
committed by GitHub
3 changed files with 23 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed ### Fixed
- Fixed `ZeroDivisionError` in `resolve_fraction_unit` https://github.com/Textualize/textual/issues/2502
- Fixed `TreeNode.expand` and `TreeNode.expand_all` not posting a `Tree.NodeExpanded` message https://github.com/Textualize/textual/issues/2535 - Fixed `TreeNode.expand` and `TreeNode.expand_all` not posting a `Tree.NodeExpanded` message https://github.com/Textualize/textual/issues/2535
- Fixed `TreeNode.collapse` and `TreeNode.collapse_all` not posting a `Tree.NodeCollapsed` message https://github.com/Textualize/textual/issues/2535 - Fixed `TreeNode.collapse` and `TreeNode.collapse_all` not posting a `Tree.NodeCollapsed` message https://github.com/Textualize/textual/issues/2535
- Fixed `TreeNode.toggle` and `TreeNode.toggle_all` not posting a `Tree.NodeExpanded` or `Tree.NodeCollapsed` message https://github.com/Textualize/textual/issues/2535 - Fixed `TreeNode.toggle` and `TreeNode.toggle_all` not posting a `Tree.NodeExpanded` or `Tree.NodeCollapsed` message https://github.com/Textualize/textual/issues/2535

View File

@@ -143,7 +143,7 @@ def resolve_fraction_unit(
resolved: list[Fraction | None] = [None] * len(resolve) resolved: list[Fraction | None] = [None] * len(resolve)
remaining_fraction = Fraction(sum(scalar.value for scalar, _, _ in resolve)) remaining_fraction = Fraction(sum(scalar.value for scalar, _, _ in resolve))
while True: while remaining_fraction > 0:
remaining_space_changed = False remaining_space_changed = False
resolve_fraction = Fraction(remaining_space, remaining_fraction) resolve_fraction = Fraction(remaining_space, remaining_fraction)
for index, (scalar, min_value, max_value) in enumerate(resolve): for index, (scalar, min_value, max_value) in enumerate(resolve):
@@ -166,7 +166,7 @@ def resolve_fraction_unit(
return ( return (
Fraction(remaining_space, remaining_fraction) Fraction(remaining_space, remaining_fraction)
if remaining_space if remaining_space > 0
else Fraction(1) else Fraction(1)
) )

View File

@@ -1,4 +1,5 @@
from fractions import Fraction from fractions import Fraction
from itertools import chain
import pytest import pytest
@@ -122,3 +123,22 @@ def test_resolve_fraction_unit():
Fraction(32), Fraction(32),
resolve_dimension="width", resolve_dimension="width",
) == Fraction(2) ) == Fraction(2)
def test_resolve_issue_2502():
"""Test https://github.com/Textualize/textual/issues/2502"""
widget = Widget()
widget.styles.width = "1fr"
widget.styles.min_width = 11
assert isinstance(
resolve_fraction_unit(
(widget.styles,),
Size(80, 24),
Size(80, 24),
Fraction(10),
resolve_dimension="width",
),
Fraction,
)