`text-wrap: nowrap` with `line-pad` filling the width raises `ValueError: range() arg 3 must not be zero`
まだ誰も着手していません。
評価
調査の方向性
クラッシュの原因は textual/content.py の get_height(613行付近)です。ここで width - line_pad * 2 を _wrap_and_format に渡しており、nowrap + fold の分岐(670行付近)がそれを range のステップとして使っています。再現アプリを Static { width: 2; line-pad: 1; text-wrap: nowrap; } で実行し、ValueError を確認してください。このレイアウトが例外を発生させずに高さを返し、幅ゼロの場合が既存の負の幅と同じように扱われれば完了です。折り返しの経路が幅0で Rich の divide_line に到達する件(rich#4234)は別の問題なので、今回の対象外のままにしてください。
索引モデルが issue の本文から書いたものです。
説明
Hi! I hit this while writing generated tests against Textual's widgets. When a widget's line-pad takes up its whole content width and text-wrap is nowrap, measuring its height crashes.
from textual.app import App, ComposeResult
from textual.widgets import Static
class LinePadApp(App):
CSS = "Static { width: 2; line-pad: 1; text-wrap: nowrap; }"
def compose(self) -> ComposeResult:
yield Static("Hello")
if __name__ == "__main__":
LinePadApp().run()
Expected: an (empty-looking) two-cell widget.
Actual (on Textual 8.2.7 with Rich 15.0.0, and on main at 5e5b7ef with Rich 14.2.0 and with Rich main):
File "textual/content.py", line 613, in get_height
lines = self.without_spans._wrap_and_format(
width - line_pad, overflow=overflow, no_wrap=no_wrap
)
File "textual/content.py", line 670, in _wrap_and_format
cuts = list(range(0, line.cell_length, width))[1:]
ValueError: range() arg 3 must not be zero
get_height passes width - line_pad * 2, which is 0 here, and the nowrap + fold branch uses it as a range step. A width less than 0 (for example width: 1) gives an empty range and doesn't raise.
With wrapping on (the default), the same layout reaches Rich's divide_line with width 0, which is rich#4234. A plain Button with width: 2; min-width: 0 hits that one, with Rich 15.
I'd suggest skipping the cuts when the width is 0 or less, which is what already happens for negative widths. I'm happy to send a PR.
- 主要言語
- Python
- スター
- 37.7k
- フォーク
- 1.5k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Textualize/textual のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6790 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
Textualize/textual#6789 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6787 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Textualize/textual#6778 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Textualize/textual#6777 · コメント 1 件 ·
Textualize/textual の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mohanraj00/entelos#200 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
-
sweep
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
bketelsen/truenas-mcp#77 ·
メンテナーはふだん 1 日以内に返信
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskオープン
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
sandbox-quantum/switch#2163 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
openedx/xblock-lti-consumer#765 ·
メンテナーはふだん 1 日以内に返信