Fix trailing space before a wrapped long word if the line length with
a space is exactly "width".
(cherry picked from commit
1c598e04361dbfc9cf465f3a02f83715c11b028c)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
# bug 1146. Prevent a long word to be wrongly wrapped when the
# preceding word is exactly one character shorter than the width
self.check_wrap(self.text, 12,
- ['Did you say ',
+ ['Did you say',
'"supercalifr',
'agilisticexp',
'ialidocious?',
def test_max_lines_long(self):
self.check_wrap(self.text, 12,
- ['Did you say ',
+ ['Did you say',
'"supercalifr',
'agilisticexp',
'[...]'],
# 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.
- if self.break_long_words:
+ if self.break_long_words and space_left > 0:
end = space_left
chunk = reversed_chunks[-1]
if self.break_on_hyphens and len(chunk) > space_left:
--- /dev/null
+Fix trailing space before a wrapped long word if the line length is exactly
+*width* in :mod:`textwrap`.