From 084b4e88c29218764a5a4c9fa442cd417293eab0 Mon Sep 17 00:00:00 2001 From: Don Yin Date: Sat, 24 Oct 2026 03:49:48 +0100 Subject: [PATCH] Keep selected fuzzy completions readable on white foregrounds Signed-off-by: Don Yin --- src/prompt_toolkit/styles/defaults.py | 2 +- tests/test_default_style.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/test_default_style.py diff --git a/src/prompt_toolkit/styles/defaults.py b/src/prompt_toolkit/styles/defaults.py index 2faba9437..6b60c8248 100644 --- a/src/prompt_toolkit/styles/defaults.py +++ b/src/prompt_toolkit/styles/defaults.py @@ -74,7 +74,7 @@ ("completion-menu.completion fuzzymatch.outside", "fg:#444444"), ("completion-menu.completion fuzzymatch.inside", "bold"), ("completion-menu.completion fuzzymatch.inside.character", "underline"), - ("completion-menu.completion.current fuzzymatch.outside", "fg:default"), + ("completion-menu.completion.current fuzzymatch.outside", "fg:#444444"), ("completion-menu.completion.current fuzzymatch.inside", "nobold"), # Styling of readline-like completions. ("readline-like-completions", ""), diff --git a/tests/test_default_style.py b/tests/test_default_style.py new file mode 100644 index 000000000..81ca53e4d --- /dev/null +++ b/tests/test_default_style.py @@ -0,0 +1,13 @@ +from prompt_toolkit.styles.defaults import default_ui_style + + +def test_selected_fuzzy_completion_outside_colors() -> None: + attrs = default_ui_style().get_attrs_for_style_str( + "class:completion-menu.completion.current class:fuzzymatch.outside" + ) + + # Reverse makes the foreground the background: it must not depend on the + # terminal foreground, which can be white like the selected text. + assert attrs.color == "444444" + assert attrs.bgcolor == "ffffff" + assert attrs.reverse