|
11 | 11 | from textual.binding import Binding, BindingType
|
12 | 12 | from textual.cache import LRUCache
|
13 | 13 | from textual.css.styles import RulesMap
|
14 |
| -from textual.geometry import Region, Size, clamp |
| 14 | +from textual.geometry import Region, Size, Spacing, clamp |
15 | 15 | from textual.message import Message
|
16 | 16 | from textual.reactive import reactive
|
17 | 17 | from textual.scroll_view import ScrollView
|
@@ -272,7 +272,7 @@ def __init__(
|
272 | 272 | self._option_to_index: dict[Option, int] = {}
|
273 | 273 | """Maps an Option to it's index in self._options."""
|
274 | 274 |
|
275 |
| - self._option_render_cache: LRUCache[tuple[Option, Style], list[Strip]] |
| 275 | + self._option_render_cache: LRUCache[tuple[Option, Style, Spacing], list[Strip]] |
276 | 276 | self._option_render_cache = LRUCache(maxsize=1024 * 2)
|
277 | 277 | """Caches rendered options."""
|
278 | 278 |
|
@@ -658,7 +658,7 @@ def _clear_caches(self) -> None:
|
658 | 658 | self.refresh()
|
659 | 659 |
|
660 | 660 | def notify_style_update(self) -> None:
|
661 |
| - self._clear_caches() |
| 661 | + self.refresh() |
662 | 662 | super().notify_style_update()
|
663 | 663 |
|
664 | 664 | def _on_resize(self):
|
@@ -741,7 +741,7 @@ def _get_option_render(self, option: Option, style: Style) -> list[Strip]:
|
741 | 741 | padding = self.get_component_styles("option-list--option").padding
|
742 | 742 | render_width = self.scrollable_content_region.width
|
743 | 743 | width = render_width - self._get_left_gutter_width()
|
744 |
| - cache_key = (option, style) |
| 744 | + cache_key = (option, style, padding) |
745 | 745 | if (strips := self._option_render_cache.get(cache_key)) is None:
|
746 | 746 | visual = self._get_visual(option)
|
747 | 747 | if padding:
|
|
0 commit comments