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

Fix space issues at the end of input string #21

Merged
merged 1 commit into from Jul 23, 2017
Merged

Conversation

SamVerschueren
Copy link
Contributor

This PR fixes the jumpy spaces in log-update. Let me explain what's going on.

Suppose we have a input string like this

'123456789\n '

The string is cut into separate lines

['123456789', ' ']

Let's wrap at 5. The first word is split on spaces, which it doesn't have so we can then cut at the 5th character.

['12345\n6789', ...]

The next word (empty space) is now taken being processed. The word is split at a space character, and thus that line now has 2 words.

['', '']

Because of this line, this word will now end up as 2 spaces, and thus has one space to many.

['12345\n6789', ' ']

I fixed this by bailing out early.

@sindresorhus
Copy link
Member

Good detective work!

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