FuzzyCompleter: unreadable parts on selected row with white terminal fg
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 10.6k
- Forks
- 837
- Ø Merge
- 15 Std. 43 Min.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus prompt-toolkit/python-prompt-toolkit
-
`PromptSession.prompt()` ignores `validator=None`Evtl. vergeben @cumminskd hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
prompt-toolkit/python-prompt-toolkit#2159 ·
Maintainer antworten meist innerhalb von 1 Tag
-
ANSI.format lets a C1 CSI set a colorEvtl. vergeben @SashaMIT hat das vor 27 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
prompt-toolkit/python-prompt-toolkit#2113 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add CSharp Console to PROJECTS.rstEvtl. vergeben @jw9829 hat das vor 32 Tagen übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
prompt-toolkit/python-prompt-toolkit#2102 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Document.translate_row_col_to_index does not clamp negative rows to zeroEvtl. vergeben @oodadoudou hat das vor 47 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
prompt-toolkit/python-prompt-toolkit#2097 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Modified arrow keys resolve to the opposite direction: ESC[1;6A is Ctrl+Shift+Up but maps to ControlShiftDown (10 entries)Evtl. vergeben @despotak hat das vor 53 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 92/100
prompt-toolkit/python-prompt-toolkit#2092 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in prompt-toolkit/python-prompt-toolkit
Ähnliche Issues
-
area/profiles comp/cli P3 type/feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
NousResearch/hermes-agent#146372 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] OpenAI-compatible embedding model alias breaks embedder constructionEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
[oblt-aw][autodoc] Document obs-aw-automerge contract and fix automerge doc inconsistenciesEvtl. vergeben @github-actions hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
GeoSeries scale and skew tests fail with pytest 9.2.0Evtl. vergeben @jiayuasu hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
admission-deferred priority: medium status: ready work-class: scoped
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
melodic-software/claude-code-plugins#10887 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag