Fix an endcase bug: initial_indent was ignored when the text was short

enough to fit in one line.
This commit is contained in:
Guido van Rossum 2002-10-02 15:47:32 +00:00
parent fb4d6ecd07
commit eb287a2662
2 changed files with 16 additions and 5 deletions

View file

@ -237,8 +237,9 @@ class TextWrapper:
converted to space.
"""
text = self._munge_whitespace(text)
if len(text) <= self.width:
return [text]
indent = self.initial_indent
if len(text) + len(indent) <= self.width:
return [indent + text]
chunks = self._split(text)
if self.fix_sentence_endings:
self._fix_sentence_endings(chunks)