Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework wrap to have simpler usage pattern #1395

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

shadowspawn
Copy link
Collaborator

Pull Request

The wrap routine is now exposed and should make sense alone.

Problem

The wrap routine was a bit hard to understand in isolation or use for new calls. It does produce
a column of width characters excluding the indent, but the column looks misaligned in the result.

Conceptually:

      1234567890
term  d e s c r i p t i o n
123456


wrap('d e s c r i p t i o n', 10, 6):
d e s c r
     i p t i o n

put back together to form

term  d e s c r i
      p t i o n

Solution

Pass in the full text. The width is now the total line length to wrap at, so closely related to the terminal width. The resulting string looks wrapped.

12345678901234567890
term  d e s c r i p t i o n

wrap('term  d e s c r i p t i o n', 16, 6):
term  d e s c r
      i p t i o n

Copy link
Collaborator

@abetomo abetomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Nov 20, 2020
@shadowspawn shadowspawn added this to the v7.0.0 milestone Nov 20, 2020
@shadowspawn shadowspawn merged commit 4555881 into tj:release/7.x Nov 20, 2020
@shadowspawn shadowspawn deleted the feature/simpler-wrap branch November 20, 2020 06:40
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants