EllipsisMiddleTruncate exceeds requested width when only the ellipsis fits
評估
研究方向
從fire/formatting.py開始,檢查EllipsisMiddleTruncate,重點關注長度為零的後半部分,以及不進行截斷的邊界。重現 issue 中的兩個範例,接著確認輸出不超過要求的寬度,並保留剛好容納得下的字串。
由索引模型根據 Issue 內容生成。
描述
EllipsisMiddleTruncate returns more characters than the requested width when available_space is 3. It also modifies strings that already fit exactly within the specified width.
Steps to reproduce
from fire import formatting
print(formatting.EllipsisMiddleTruncate('abcdefghij', 3, 80))
# Actual: '...abcdefghij'
# Expected: '...'
print(formatting.EllipsisMiddleTruncate('abcd', 4, 80))
# Actual: '...d'
# Expected: 'abcd'
Cause
The expression text[-second_half_len:] returns the entire string when second_half_len is zero. The no-truncation check also uses < instead of <=.
Expected behavior
Output should respect the available width, and strings that already fit should remain unchanged.
Verification
Reproduced using the implementation from fire/formatting.py.
- 主要語言
- Python
- 星號
- 28.2k
- 分支
- 1.5k
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
google/python-fire 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
google/python-fire#733 ·
-
External pager resets custom SIGINT handlers to SIG_DFL可能已有人在做 @hugosmoreira 於 14 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
google/python-fire#723 · 1 則留言 ·
-
Windows ANSI initialization uses nonexistent subprocess.STD_OUTPUT_HANDLE可能已有人在做 @Fire162 於 11 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
google/python-fire#721 · 1 則留言 ·
-
Setup docs still say `python setup.py install`, but `setup.py` was removed可能已有人在做 @GreedyC 於 18 天前認領。 未關閉
難度 1/5 1-3 小時 新手友好度 93/100
google/python-fire#718 · 1 則留言 ·
-
Calling an async command from an active event loop raises RuntimeError and leaves an unawaited coroutine可能已有人在做 @aashish254 於 20 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
google/python-fire#716 ·
查看 google/python-fire 的全部 Issue
相似的 Issue
-
難度 1/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
bug documentation good first issue help wanted testing
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
Show evidence time and supersede warnings in the memory inspector可能已有人在做 @Sinchanak-212 今天認領。 未關閉area: ux good first issue priority: medium
難度 2/5 1-3 小時 新手友好度 84/100
-
難度 1/5 1 小時以內 新手友好度 86/100
daniel-ospina/tortoise#11649 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 86/100
ComposioHQ/awesome-claude-skills#2438 ·
維護者通常 15 天內回覆