Skip to content

Commit

Permalink
squash: mor reflow, fighting the uphill battle...
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Sep 4, 2023
1 parent 17641a6 commit 88a6e71
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion spec/stories/priority.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ story:
be implemented, which are important and which are desirable
but not necessary.

description: >
description: |
All user stories are important, but they are prioritized to
deliver the greatest and most immediate benefits early. When
working on implementation developers should prioritize their
Expand Down
27 changes: 20 additions & 7 deletions tmt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2957,23 +2957,36 @@ def _format_str(

# UX: if the window size is known, rewrap lines to fit in. Otherwise, put
# each line on its own, well, line.
# Work with *paragraphs* - lines within a paragraph may get reformatted to
# fit the line, but we should preserve empty lines between paragraps as
# much as possible.
is_multiline = bool('\n' in value)

if window_size:
for paragraph in value.rstrip().split('\n\n'):
paragraph = paragraph.rstrip()
stripped_paragraph = paragraph.rstrip()

if not paragraph:
if not stripped_paragraph:
yield ''

elif wrap is False:
yield paragraph
yield ''
yield stripped_paragraph

if is_multiline:
yield ''

else:
yield from textwrap.wrap(paragraph, width=window_size)
yield ''
if all(len(line) <= window_size for line in stripped_paragraph.splitlines()):
yield from stripped_paragraph.splitlines()

else:
yield from textwrap.wrap(stripped_paragraph, width=window_size)

if is_multiline:
yield ''

else:
if not value.strip():
if not value.rstrip():
yield ''

else:
Expand Down

0 comments on commit 88a6e71

Please sign in to comment.