Skip to content

Commit

Permalink
Strip trailing whitespace with pdm-show
Browse files Browse the repository at this point in the history
pdm-show uses `project.core.ui.display`, which adds trailing spaces to all the
lines (based on the longest one), which results in them being displayed/wrapped
when the terminal is not wide enough for the longest line:

```
% pdm show coverage|cat -A
Name:                  coverage                                      $
Latest version:        6.0.2                                         $
…
Project URLs:          Documentation: https://coverage.readthedocs.io$
                       Funding: https://example.com/?utm_source=foo&…$
…
```

This patch just adds `rstrip()`, which gets rid of it, while still
keeping the maybe too long underline for the header (not used with
pdm-show).

Maybe this could use $COLUMNS / the terminal width to limit the length
of the header underline, but that is not really needed / not trivial.
  • Loading branch information
blueyed committed Oct 13, 2021
1 parent a5ef1fa commit ab65cad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pdm/termui.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get_aligner(align: str) -> Callable:
" ".join(
aligner(head, size)
for aligner, head, size in zip(aligners, header, sizes)
)
).rstrip()
)
# Print a separator
self.echo(" ".join("-" * size for size in sizes))
Expand All @@ -155,7 +155,7 @@ def get_aligner(align: str) -> Callable:
" ".join(
aligner(item, size)
for aligner, item, size in zip(aligners, row, sizes)
)
).rstrip()
)

@contextlib.contextmanager
Expand Down

0 comments on commit ab65cad

Please sign in to comment.