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

Release #1881

Merged
merged 2 commits into from
Dec 26, 2024
Merged

Release #1881

merged 2 commits into from
Dec 26, 2024

Conversation

wang1212
Copy link
Member

No description provided.

wang1212 and others added 2 commits December 26, 2024 20:52
* fix: text wrapping boundary cases

* chore: remove log
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copy link

Walkthrough\nThis pull request primarily updates the dependencies across multiple packages within the repository, specifically upgrading to @antv/g-lite@2.2.12. It also includes a fix for text wrapping boundary cases in the TextService.ts file.\n\n### Changes\n| Files | Summary |\n|-------|---------|\n| packages/*/CHANGELOG.md | Added entries for new patch versions with updated dependencies. |\n| packages/*/package.json | Updated dependency versions. |\n| packages/g-lite/src/services/TextService.ts | Fixed text wrapping boundary cases by adjusting character index handling. |

@@ -391,7 +391,7 @@ export class TextService {
textCharIndex += 1;
txt += chars[textCharIndex];
}
while (calcWidth(txt) > widthThreshold) {
while (calcWidth(txt) > widthThreshold && textCharIndex > 0) {

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);

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,

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) {

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;

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);

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.

@wang1212 wang1212 merged commit c492468 into next Dec 26, 2024
4 checks passed
@wang1212 wang1212 deleted the release branch December 26, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants