@@ -137,6 +137,44 @@ def test_prompt_highlight_coexist():
137137 assert ic ._get_choice_tokens () == expected_tokens
138138
139139
140+ def test_prompt_highlight_selected_with_custom_styles ():
141+ # formatted-text (list) titles should keep their custom style and also
142+ # pick up the highlighted/selected style (see #151)
143+ ic = InquirerControl (
144+ [
145+ Choice (title = [("fg:red" , "a" )]),
146+ Choice (title = [("fg:blue" , "b" )], checked = True ),
147+ ]
148+ )
149+
150+ expected_tokens = [
151+ ("class:pointer" , " » " ),
152+ ("[SetCursorPosition]" , "" ),
153+ ("class:text" , "○ " ),
154+ ("fg:red class:highlighted" , "a" ),
155+ ("" , "\n " ),
156+ ("class:text" , " " ),
157+ ("class:selected" , "● " ),
158+ ("fg:blue class:selected" , "b" ),
159+ ]
160+ assert ic .pointed_at == 0
161+ assert ic ._get_choice_tokens () == expected_tokens
162+
163+ ic .select_next ()
164+ expected_tokens = [
165+ ("class:text" , " " ),
166+ ("class:text" , "○ " ),
167+ ("fg:red" , "a" ),
168+ ("" , "\n " ),
169+ ("class:pointer" , " » " ),
170+ ("[SetCursorPosition]" , "" ),
171+ ("class:selected" , "● " ),
172+ ("fg:blue class:selected" , "b" ),
173+ ]
174+ assert ic .pointed_at == 1
175+ assert ic ._get_choice_tokens () == expected_tokens
176+
177+
140178def test_prompt_show_answer_with_shortcuts ():
141179 ic = InquirerControl (
142180 ["a" , Choice ("b" , shortcut_key = False ), "c" ],
0 commit comments