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

Avoid truncation for inputs close to limit #57

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

Conversation

bhavanki
Copy link

Previous truncation code always truncated and added a tail once the processed input width exceeded the limit minus the tail width. For example, the input "foobar" truncated to width 6 with a tail "." would come out as "fooba.".

Now, when the rune scanning loop passes into the danger zone where truncation might be required, but before the truncation limit is breached, it buffers runes instead of writing them out. If the truncation limit is exceeded, then the tail is written as usual. If it ends up not exceeded, then the buffered runes are written out, avoiding unnecessary truncation.

Previous truncation code always truncated and added a tail once the
processed input width exceeded the limit minus the tail width. For
example, the input "foobar" truncated to width 6 with a tail "." would
come out as "fooba.".

Now, when the rune scanning loop passes into the danger zone where
truncation might be required, but before the truncation limit is
breached, it buffers runes instead of writing them out. If the
truncation limit is exceeded, then the tail is written as usual. If it
ends up not exceeded, then the buffered runes are written out, avoiding
unnecessary truncation.
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

1 participant