]> granicus.if.org Git - python/commitdiff
Fix SF bug #622849: in _wrap_chunks(), ensure that leading whitespace in
authorGreg Ward <gward@python.net>
Mon, 9 Dec 2002 16:26:05 +0000 (16:26 +0000)
committerGreg Ward <gward@python.net>
Mon, 9 Dec 2002 16:26:05 +0000 (16:26 +0000)
the input string is always preserved.

Lib/textwrap.py

index fc93b9b0afddd782d42c51034fc521735fae854f..5860d7de63bc48953f5f3e46887ddf8b7633f063 100644 (file)
@@ -202,8 +202,9 @@ class TextWrapper:
             # Maximum width for this line.
             width = self.width - len(indent)
 
-            # First chunk on line is whitespace -- drop it.
-            if chunks[0].strip() == '':
+            # First chunk on line is whitespace -- drop it, unless this
+            # is the very beginning of the text (ie. no lines started yet).
+            if chunks[0].strip() == '' and lines:
                 del chunks[0]
 
             while chunks: