-
Notifications
You must be signed in to change notification settings - Fork 208
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
Release #1881
Conversation
* fix: text wrapping boundary cases * chore: remove log
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Walkthrough\nThis pull request primarily updates the dependencies across multiple packages within the repository, specifically upgrading to
|
@@ -391,7 +391,7 @@ export class TextService { | |||
textCharIndex += 1; | |||
txt += chars[textCharIndex]; | |||
} | |||
while (calcWidth(txt) > widthThreshold) { | |||
while (calcWidth(txt) > widthThreshold && textCharIndex > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that textCharIndex > 0
is checked to prevent potential underflow when decrementing textCharIndex
. This change helps avoid errors when calcWidth(txt)
is greater than widthThreshold
.
@@ -436,7 +436,7 @@ export class TextService { | |||
parsedStyle.isOverflowing = true; | |||
|
|||
if (i < chars.length - 1) { | |||
appendEllipsis(currentLineIndex, i); | |||
appendEllipsis(currentLineIndex, i - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusting the index for appendEllipsis
ensures that the ellipsis is appended correctly without overshooting the character index.
@@ -452,17 +452,17 @@ export class TextService { | |||
if (currentLineWidth > 0 && currentLineWidth + charWidth > maxWidth) { | |||
const result = findCharIndexClosestWidthThreshold( | |||
lines[currentLineIndex], | |||
i, | |||
i - 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The adjustment of i - 1
ensures that the character index is correctly aligned with the width threshold, preventing potential off-by-one errors.
maxWidth, | ||
); | ||
if (result.textCharIndex !== i) { | ||
if (result.textCharIndex !== i - 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that the comparison result.textCharIndex !== i - 1
correctly reflects the intended logic to prevent incorrect text slicing.
lines[currentLineIndex] = result.txt; | ||
|
||
if (result.textCharIndex === chars.length - 1) { | ||
break; | ||
} | ||
|
||
i = result.textCharIndex; | ||
i = result.textCharIndex + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incrementing i
by 1 after setting it to result.textCharIndex
ensures that the loop continues correctly without skipping characters.
@@ -472,7 +472,7 @@ export class TextService { | |||
if (currentLineIndex + 1 >= maxLines) { | |||
parsedStyle.isOverflowing = true; | |||
|
|||
appendEllipsis(currentLineIndex, i); | |||
appendEllipsis(currentLineIndex, i - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusting the index for appendEllipsis
ensures that the ellipsis is appended correctly without overshooting the character index.
No description provided.