Skip to content

Commit d3c5e78

Browse files
committed
snapshot fix
1 parent 9ec6ae5 commit d3c5e78

File tree

3 files changed

+181
-1
lines changed

3 files changed

+181
-1
lines changed

src/textual/canvas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def __init__(self, width: int, height: int) -> None:
157157
self._width = width
158158
self._height = height
159159
blank_line = " " * width
160-
self.lines: list[array[str]] = [array("u", blank_line) for _ in range(height)]
160+
self.lines: list[array[str]] = [array("w", blank_line) for _ in range(height)]
161161
self.box: list[defaultdict[int, Quad]] = [
162162
defaultdict(lambda: (0, 0, 0, 0)) for _ in range(height)
163163
]
Lines changed: 150 additions & 0 deletions
Loading

tests/snapshot_tests/test_snapshots.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,3 +3893,33 @@ def on_mount(self) -> None:
38933893
)
38943894

38953895
snap_compare(ToastApp())
3896+
3897+
3898+
# Thanks Tom Gooding
3899+
def test_alignment_with_auto_and_min_height(snap_compare):
3900+
"""Regression test for https://github.com/Textualize/textual/issues/5608
3901+
You should see a blue label that is centered both horizontally and vertically
3902+
within a pink container. The container has auto width and height, but also
3903+
a min-width of 20 and a min-height of 3.
3904+
"""
3905+
3906+
class AlignmentApp(App):
3907+
CSS = """
3908+
Container {
3909+
align: center middle;
3910+
height: auto;
3911+
min-height: 3;
3912+
width: auto;
3913+
min-width: 20;
3914+
background: pink;
3915+
}
3916+
Label {
3917+
background: blue;
3918+
}
3919+
"""
3920+
3921+
def compose(self) -> ComposeResult:
3922+
with Container():
3923+
yield Label("centered")
3924+
3925+
snap_compare(AlignmentApp())

0 commit comments

Comments
 (0)