Skip to content

Commit

Permalink
optimize scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Nov 30, 2024
1 parent a913540 commit 8c84274
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/textual/scroll_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ def _size_updated(
layout: Perform layout if required.
Returns:
True if anything changed, or False if nothing changed.
True if a resize event should be sent, otherwise False.
"""
if self._size != size or self._container_size != container_size:
self.refresh()
if (
self._size != size
or virtual_size != self.virtual_size
Expand All @@ -96,9 +94,8 @@ def _size_updated(
virtual_size = self.virtual_size
self._container_size = size - self.styles.gutter.totals
self._scroll_update(virtual_size)
return True
else:
return False

return self._size != size or self._container_size != container_size

def render(self) -> RenderableType:
"""Render the scrollable region (if `render_lines` is not implemented).
Expand Down
3 changes: 2 additions & 1 deletion src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3695,8 +3695,9 @@ def _size_updated(
layout: Perform layout if required.
Returns:
True if anything changed, or False if nothing changed.
True if a resize event should be sent, otherwise False.
"""

self._layout_cache.clear()
if (
self._size != size
Expand Down
1 change: 0 additions & 1 deletion src/textual/widgets/_option_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,6 @@ def get_option_index(self, option_id: str) -> int:
) from None

def render_line(self, y: int) -> Strip:
self._populate()
assert self._lines is not None

_scroll_x, scroll_y = self.scroll_offset
Expand Down

0 comments on commit 8c84274

Please sign in to comment.