Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

FuzzyCompleter: unreadable parts on selected row with white terminal fg

オープン
#2,007 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
cli

調査の方向性

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:
Image

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"),:
Image

Edit: I don't know what the intended look was supposed to be, but considering that:

  1. terminals are usually white-on-black
  2. the 'outside' foreground color is hardcoded
  3. 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"),:
Image
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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

prompt-toolkit/python-prompt-toolkit のほかの issue

prompt-toolkit/python-prompt-toolkit の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。