Skip to content

Commit 0f66151

Browse files
authored
Merge pull request #5766 from paul-ollis/optionlist
Prevent OptionList causing excessive redraws.
2 parents ed1f940 + 17a919a commit 0f66151

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
### Fixed
9+
10+
- Fixed `OptionList` causing excessive redrawing https://github.com/Textualize/textual/pull/5766
811

912
## [3.1.1] - 2025-04-22
1013

src/textual/widgets/_option_list.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class OptionList(ScrollView, can_focus=True):
165165
}
166166
& > .option-list--option-hover {
167167
background: $block-hover-background;
168-
}
168+
}
169169
}
170170
"""
171171

@@ -784,8 +784,10 @@ def _update_lines(self) -> None:
784784
)
785785

786786
last_divider = self.options and self.options[-1]._divider
787-
self.virtual_size = Size(width, len(lines) - (1 if last_divider else 0))
788-
self._scroll_update(self.virtual_size)
787+
virtual_size = Size(width, len(lines) - (1 if last_divider else 0))
788+
if virtual_size != self.virtual_size:
789+
self.virtual_size = virtual_size
790+
self._scroll_update(virtual_size)
789791

790792
def get_content_width(self, container: Size, viewport: Size) -> int:
791793
"""Get maximum width of options."""

0 commit comments

Comments
 (0)