Skip to content
Myr

Fixed a bug with whitespace preservation.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent ca1dff9 · Browse files · 2 files+18 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+18 added−5 removed

  • tests:+9 added−0 removed
  • other:+9 added−5 removed

2 files+18 added−5 removed

modified:click/formatting.py+9 added-5 removed
87 unmodified lines
88 return wrapper.fill(text)8990 p = []91 buf = []92 indent = 092 indent = None9394 def _flush_par():95 if not buf:96 return97 if buf[0].lstrip() == '\b':98 p.append((indent, True, '\n'.join(buf[1:])))98 p.append((indent or 0, True, '\n'.join(buf[1:])))99 else:100 p.append((indent, False, ' '.join(buf)))100 p.append((indent or 0, False, ' '.join(buf)))101 del buf[:]102103 for line in text.splitlines():104 if not line:105 _flush_par()106 indent = None107 else:107 indent = len(line) - len(line.lstrip())108 buf.append(line.lstrip())108 if indent is None:109 orig_len = len(line)110 line = line.lstrip()111 indent = orig_len - len(line)112 buf.append(line)113 _flush_par()114115 rv = []116 for indent, raw, text in p:
144 unmodified lines
modified:tests/test_formatting.py+9 added
14 unmodified lines
15 This is16 a paragraph17 without rewrapping.1819 \b20 121 222 32324 And this is a paragraph25 that will be rewrapped again.26 """27
10 unmodified lines
38 ' This is',39 ' a paragraph',40 ' without rewrapping.',41 '',42 ' 1',43 ' 2',44 ' 3',45 '',46 ' And this is a paragraph that will be rewrapped again.',47 '',48 'Options:',49 ' --help Show this message and exit.',
1 unmodified line