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

padding is not based on the true length (wcwidth) of paddingChr #17

Open
danyshaanan opened this issue Aug 11, 2014 · 4 comments
Open
Assignees
Labels

Comments

@danyshaanan
Copy link
Collaborator

For instance, { paddingChr: chalk.gray('.') } will break format.

Problem is within utils.js::repeatString which uses slice.

@danyshaanan danyshaanan self-assigned this Aug 11, 2014
@timoxley
Copy link
Owner

Good call.

@danyshaanan
Copy link
Collaborator Author

@timoxley : when wcwidth(str)===1, (like with chalk.gray('.')) droping the slice(0,len) solves it (relevant line), but when wcwidth(str)>1 it's not always possible to multiply it several times to get the required length, and it is required to trim the last occurrence. Any idea how to properly trim such a string?

i.e. How can I slice the first two visual chars of chalk.gray('123') without messing the colors?

@timoxley
Copy link
Owner

I think the only way to do this would be to pass it through something like sindresorhus/strip-ansi first.

@danyshaanan
Copy link
Collaborator Author

That would enable slicing out the actual wanted length, but is there any reasonable way to colour it again before concatenating to the padding?

I'm starting to think that there is no way to do this, meaning we should disallow wcwidth(padding) > 1, wcwidth(padding) !== padding.length), or preferably, the combination of the two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants