From 13e796bfea55c557669ca8eb12d2a365dbf7ea78 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Mon, 22 May 2023 14:56:21 +0100 Subject: [PATCH] Ensure selections are only one line in length --- src/textual/widgets/_selection_list.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/textual/widgets/_selection_list.py b/src/textual/widgets/_selection_list.py index 98c95fe4e..0bfba439d 100644 --- a/src/textual/widgets/_selection_list.py +++ b/src/textual/widgets/_selection_list.py @@ -7,7 +7,7 @@ from typing import ClassVar, Generic, TypeVar, cast from rich.repr import Result from rich.segment import Segment from rich.style import Style -from rich.text import TextType +from rich.text import Text, TextType from typing_extensions import Self from ..binding import Binding @@ -46,7 +46,9 @@ class Selection(Generic[SelectionType], Option): id: The optional ID for the selection. disabled: The initial enabled/disabled state. Enabled by default. """ - super().__init__(prompt, id, disabled) + if isinstance(prompt, str): + prompt = Text.from_markup(prompt) + super().__init__(prompt.split()[0], id, disabled) self._value: SelectionType = value @property