FuzzyCompleter: unreadable parts on selected row with white terminal fg
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 10.6k
- フォーク
- 825
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
prompt-toolkit/python-prompt-toolkit のほかの issue
-
ANSI.format lets a C1 CSI set a color対応中かも @SashaMIT が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Add CSharp Console to PROJECTS.rst対応中かも @jw9829 が 14 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
-
Document.translate_row_col_to_index does not clamp negative rows to zero対応中かも @oodadoudou が 29 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Modified arrow keys resolve to the opposite direction: ESC[1;6A is Ctrl+Shift+Up but maps to ControlShiftDown (10 entries)対応中かも @despotak が 35 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
-
TelnetServer recv error: Forcing an RST request to the telnet server can cause a crash対応中かも @liyimil が 85 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
prompt-toolkit/python-prompt-toolkit#2073 · コメント 2 件 ·
prompt-toolkit/python-prompt-toolkit の issue をすべて見る
似ている issue
-
namespace operations
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
EclipseFdn/open-vsx.org#14043 ·
メンテナーはふだん 1 日以内に返信
-
feedback simulation workshop
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
githubnext/gh-aw-workshop#4455 ·
メンテナーはふだん 1 日以内に返信
-
Triage 🩺
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_waitオープンneeds-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
krkn-chaos/krkn#1627 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NousResearch/hermes-agent#136483 ·
メンテナーはふだん 1 日以内に返信