Coverage for src/lilbee/cli/tui/widgets/clamped_option_list.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-08-14 11:46 +0000

1"""OptionList whose height measurement survives a zero-width squeeze.""" 

2 

3from __future__ import annotations 

4 

5from textual.geometry import Size 

6from textual.widgets import OptionList 

7 

8 

9class ClampedOptionList(OptionList): 

10 """Clamp the measurement width so option wrapping never sees zero. 

11 

12 Textual 8.2.8 ``OptionList.get_content_height`` feeds ``width minus the 

13 option padding`` straight into visual wrapping; when a drawer plus a tiny 

14 terminal squeeze the list to zero columns, rich's cell chopper raises 

15 ``ValueError: range() arg 3 must not be zero`` and the app dies. Keep the 

16 subtraction positive until that is fixed upstream. 

17 """ 

18 

19 def get_content_height(self, container: Size, viewport: Size, width: int) -> int: 

20 padding_width = self.get_component_styles("option-list--option").padding.width 

21 return super().get_content_height(container, viewport, max(width, padding_width + 1))