Skip to content

Add support for "surrogate pairs" in unmatched characters #3

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

webpro
Copy link

@webpro webpro commented Jun 21, 2025

Thanks for a great package, been very useful.

Hit an odd bug:

const input = "██ █";
const result = getStringTruncatedWidth(input, { limit: 2 });
// { width: 2, index: 4, truncated: true, ellipsed: true }

The index should be 2. While this looks fine:

const input = "█ ██";
const result = getStringTruncatedWidth(input, { limit: 2 });
// { width: 2, index: 2, truncated: true, ellipsed: true }

Also, not sure if you even want to support this, feel free to reject. But I've tried to fix up the unmatched part anyway. Also not sure if it's up to your vision/standards, but happy to adjust.

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.

1 participant