FuzzyCompleter: unreadable parts on selected row with white terminal fg
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
Research direction
Start in src/prompt_toolkit/styles/defaults.py at the completion-menu.completion.current and fuzzymatch.outside definitions, then run the minimal reproduction in a terminal with a white foreground. Confirm the chosen style keeps the outside fuzzy-match text readable on the selected row and preserves the intended completion-menu appearance.
Written by the indexing model from the issue text.
Description
Description of the issue
In the default style, the current completion row is defined as:
https://github.com/prompt-toolkit/python-prompt-toolkit/blob/af26eec26d4c650f7de26ae474a61b1741896c1d/src/prompt_toolkit/styles/defaults.py#L69
which sets a gray foreground and a white background, swapped by the reverse property, so it renders as white foreground on gray background.
Meanwhile, the 'outside' part of the fuzzy match (the 'completion' part) is defined as:
https://github.com/prompt-toolkit/python-prompt-toolkit/blob/af26eec26d4c650f7de26ae474a61b1741896c1d/src/prompt_toolkit/styles/defaults.py#L77
which leaves the foreground as the default from the terminal. Since the reverse property is inherited from completion-menu.completion.current, the terminal foreground becomes the displayed background for the 'outside' segment.
So, taking the swaps into account, the foreground is white (from completion-menu.completion.current) and the background comes from the terminal foreground. This is a problem when the terminal foreground is white, because then both the foreground and background colors will be white, making the 'outside' segments unreadable.
Here's a screenshot from Ubuntu stock terminal, which has a white default foreground color:
Steps to reproduce
Use this MRE in a terminal where the foreground color is white:
from prompt_toolkit import prompt
from prompt_toolkit.completion import FuzzyWordCompleter
completer = FuzzyWordCompleter(
["hullabaloo", "bamboozle", "mumbojumbo", "fizzbuzz", "zigzag", "flimflam"]
)
print(prompt("Pick one: ", completer=completer))
Suggested fix
completion-menu.completion.current has both foreground/background colors hardcoded, so the simplest fix could be to hardcode a suitable color in completion-menu.completion.current fuzzymatch.outside, replacing fg:default.
Example with ("completion-menu.completion.current fuzzymatch.outside", "fg:#444444"),:
Edit: I don't know what the intended look was supposed to be, but considering that:
- terminals are usually white-on-black
- the 'outside' foreground color is hardcoded
- the only variable is the background color, which comes from the terminal's foreground color
the look might have been intended to appear lighter?
Here's a variant with ("completion-menu.completion.current fuzzymatch.outside", "fg:#dddddd bg:#666666"),:
In this lighter version I adjusted both colors to improve readability.
Since I'm not familiar enough with prompt_toolkit to make a call on the intended styling though, I'd rather leave the choice to the maintainers.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 819
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from prompt-toolkit/python-prompt-toolkit
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
prompt-toolkit/python-prompt-toolkit#2113 ·
Maintainers usually reply within 4 days
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
prompt-toolkit/python-prompt-toolkit#2102 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
prompt-toolkit/python-prompt-toolkit#2097 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
prompt-toolkit/python-prompt-toolkit#2092 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
prompt-toolkit/python-prompt-toolkit#2073 · 2 comments ·
Maintainers usually reply within 4 days
All issues in prompt-toolkit/python-prompt-toolkit
Similar issues
-
tool-calling
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vllm-project/vllm#59838 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
raullenchai/Rapid-MLX#4042 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 92/100
transitmatters/mbta-slow-zone-bot#70 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
litestar-org/advanced-alchemy#811 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day