[BUG] Panel.fit cuts off the subtitle when it is wider than the content

オープン 初心者向け
#4,254 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
cli

調査の方向性

rich/panel.pyから始めます。issueでは、__rich_measure__と__rich_console__がタイトルを処理する一方で、サブタイトルを処理しないと指摘されています。サブタイトルの処理を既存のタイトル処理と比較し、該当するpanelのテストを実行してください。Panel.fitが長いサブタイトルを切り詰めずに含め、期待される出力と一致すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

Panel.fit widens the panel for a long title, but not for a long subtitle, so the subtitle is truncated:

from rich.console import Console
from rich.panel import Panel

Console(width=80).print(Panel.fit("Hello", title="App", subtitle="press q to quit"))
╭─ App ─╮
│ Hello │
╰─ pres─╯

With Panel.fit("x", subtitle="a long subtitle here") the bottom border is just ╰─ ─╯ and the subtitle is gone.

Expected ╰─ press q to quit ─╯, the same way a long title is handled.

In rich/panel.py, __rich_measure__ measures _title but not _subtitle, and __rich_console__ widens the panel for title_text only.

Platform

Click to expand

Linux. Reproduced with rich 14.1.0 and master (3a109ccd), output to a plain Console(width=80).

主要言語
Python
スター
57.8k
フォーク
2.6k
平均マージ
20分
マージ済み PR(30日)
3

環境構築

はじめの一歩

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

Textualize/rich のほかの issue

Textualize/rich の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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