Skip to content

Commit

Permalink
zero height renderables
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Jun 6, 2024
1 parent c2eff2d commit f72fb5d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Changed

- `get_content_height` will now return 0 if the renderable is Falsey

## [0.65.2] - 2023-06-06

### Fixed
Expand Down
1 change: 1 addition & 0 deletions examples/code_browser.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ CodeBrowser.-show-tree #tree-view {
#code-view {
overflow: auto scroll;
min-width: 100%;
hatch: right $primary;
}
#code {
width: auto;
Expand Down
5 changes: 4 additions & 1 deletion src/textual/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ async def stop_timer(timer: Timer) -> None:
if timer._task is not None:
timer._active.set()
timer._task.cancel()
await timer._task
try:
await timer._task
except CancelledError:
pass

await gather(*[stop_timer(timer) for timer in list(timers)])

Expand Down
16 changes: 10 additions & 6 deletions src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,13 +1345,17 @@ def get_content_height(self, container: Size, viewport: Size, width: int) -> int

renderable = self.render()
if isinstance(renderable, Text):
height = len(
renderable.wrap(
self._console,
width,
no_wrap=renderable.no_wrap,
tab_size=renderable.tab_size or 8,
height = (
len(
renderable.wrap(
self._console,
width,
no_wrap=renderable.no_wrap,
tab_size=renderable.tab_size or 8,
)
)
if renderable
else 0
)
else:
options = self._console.options.update_width(width).update(
Expand Down
1 change: 1 addition & 0 deletions src/textual/widgets/_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class Label(Static):
Label {
width: auto;
height: auto;
min-height: 1;
}
"""

0 comments on commit f72fb5d

Please sign in to comment.