mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
Fix #1146: TextWrap vs words 1-character shorter than the width.
Patch by Quentin Gallet-Gilles.
This commit is contained in:
parent
14404b68d8
commit
c6fde7293e
3 changed files with 22 additions and 1 deletions
|
@ -173,7 +173,12 @@ class TextWrapper:
|
|||
Handle a chunk of text (most likely a word, not whitespace) that
|
||||
is too long to fit in any line.
|
||||
"""
|
||||
space_left = max(width - cur_len, 1)
|
||||
# Figure out when indent is larger than the specified width, and make
|
||||
# sure at least one character is stripped off on every pass
|
||||
if width < 1:
|
||||
space_left = 1
|
||||
else:
|
||||
space_left = width - cur_len
|
||||
|
||||
# If we're allowed to break long words, then do so: put as much
|
||||
# of the next chunk onto the current line as will fit.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue