Skip to content

Commit

Permalink
fix height calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Aug 21, 2024
1 parent dd13211 commit 8ca4682
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/textual/widgets/_option_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,18 @@ def get_content_width(self, container: Size, viewport: Size) -> int:
)

def get_content_height(self, container: Size, viewport: Size, width: int) -> int:
# Get the content height without requiring a refresh
# TODO: Internal data structure could be simplified
style = self.rich_style
return sum(
(
1
if isinstance(content, Separator)
else len(
self._render_option_content(index, content, style, container.width)
)
)
for index, content in enumerate(self._contents)
_render_option_content = self._render_option_content
heights = [
len(_render_option_content(index, option, style, width))
for index, option in enumerate(self._options)
]
separator_count = sum(
1 for content in self._contents if isinstance(content, Separator)
)
return sum(heights) + separator_count

def _on_mouse_move(self, event: events.MouseMove) -> None:
"""React to the mouse moving.
Expand Down

0 comments on commit 8ca4682

Please sign in to comment.