TextArea (soft_wrap=False) cuts off the end of a line that has double-width characters before a tab
まだ誰も着手していません。
評価
調査の方向性
Start by comparing Document.get_size() with TextArea's expand_tabs_inline path, then run the supplied reproduction with 中中\tEND and soft_wrap=False. Done means the measured width matches the drawn cell width and the full line, including END, is visible; the reporter says they already have a PR with a test ready.
索引モデルが issue の本文から書いたものです。
説明
Hi! I hit this while writing generated tests against Textual's widgets.
With soft_wrap=False, TextArea sets its virtual width from Document.get_size(), which measures each line with cell_len(line.expandtabs(tab_width)). str.expandtabs counts a double-width character as one column, so after CJK text the tab stops land in a different place from where TextArea draws them (it uses expand_tabs_inline, which counts cells). The width can come out too small, and then the end of the line can't be seen or scrolled to.
import asyncio
import textual
from textual.app import App, ComposeResult
from textual.widgets import TextArea
TEXT = "中中\tEND" # 中中 is 4 cells, the tab pads to column 8, then END: 11 cells
class TextAreaApp(App):
def compose(self) -> ComposeResult:
yield TextArea(TEXT, soft_wrap=False, show_line_numbers=False, tab_behavior="indent")
async def main() -> None:
app = TextAreaApp()
async with app.run_test(size=(40, 5)) as pilot:
text_area = app.query_one(TextArea)
await pilot.pause()
print("indent_width:", text_area.indent_width)
print("first line on screen:", repr(text_area.render_line(0).text.rstrip()))
print("screenshot contains 'END':", "END" in app.export_screenshot())
print("document.get_size():", text_area.document.get_size(text_area.indent_width))
print("virtual_size:", text_area.virtual_size)
print("Textual", textual.__version__)
asyncio.run(main())
Output on Textual 8.2.7 (and the same on main at 5e5b7ef):
indent_width: 4
first line on screen: '中中 EN'
screenshot contains 'END': False
document.get_size(): Size(width=9, height=1)
virtual_size: Size(width=10, height=1)
The TextArea is 40 cells wide, but the "D" is never drawn: expandtabs puts the tab stop at column 4 (counting 中中 as 2 columns), so the line measures 9 cells instead of 11. I expected get_size() to measure tabs the same way the line is drawn. Using expand_tabs_inline there gives Size(width=11, height=1) and the whole line shows. I have a PR with a test ready.
- 主要言語
- 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 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6782 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Textualize/textual#6778 · コメント 1 件 ·
Textualize/textual の issue をすべて見る
似ている issue
-
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 日以内に返信
-
bug pydanty:is-working
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pydantic/pydantic-ai#13939 ·
メンテナーはふだん 1 日以内に返信
-
priority: low python
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
LearningCircuit/local-deep-research#8849 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
francescopace/espectre#223 ·
メンテナーはふだん 3 日以内に返信
-
good first issue Status: Triaged
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
canonical/imagecraft#538 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信