From 2647d548f3ebc6e26c08a52b0dda3932bc99b096 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sat, 30 Nov 2024 14:53:51 +0000 Subject: [PATCH] fix refresh --- src/textual/widgets/_option_list.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/textual/widgets/_option_list.py b/src/textual/widgets/_option_list.py index 9a0e0b66f6..5356e0fe94 100644 --- a/src/textual/widgets/_option_list.py +++ b/src/textual/widgets/_option_list.py @@ -366,8 +366,7 @@ def _add_lines( def _populate(self) -> None: """Populate the lines data-structure.""" - if self._lines is not None: - return + self._lines = [] self._spans = [] @@ -825,6 +824,8 @@ def get_option_index(self, option_id: str) -> int: def render_line(self, y: int) -> Strip: assert self._lines is not None + if not self._lines: + self._populate() _scroll_x, scroll_y = self.scroll_offset line_number = scroll_y + y