Skip to content

fix: the latest value was not used during position reversal #534

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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions src/hooks/useAlign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,9 @@ export default function useAlign(
nextOffsetY = tmpNextOffsetY;
popupOffsetY = -popupOffsetY;

nextAlignInfo.points = [
reversePoints(popupPoints, 0),
reversePoints(targetPoints, 0),
];
nextAlignInfo.points = nextAlignInfo.points.map((point) =>
Copy link
Preview

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Add a comment explaining why splitPoints is applied before reversePoints—this clarifies the transformation of a two-character string into a Points tuple for future maintainers.

Copilot uses AI. Check for mistakes.

reversePoints(splitPoints(point), 0),
);
Comment on lines +445 to +447
Copy link
Preview

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mapping logic for reversing points is repeated across multiple flip branches. Extract this into a helper (e.g., reverseAlignPoints(pointsArray, axisIndex)) to avoid duplication and improve readability.

Suggested change
nextAlignInfo.points = nextAlignInfo.points.map((point) =>
reversePoints(splitPoints(point), 0),
);
nextAlignInfo.points = reverseAlignPoints(nextAlignInfo.points, 0);

Copilot uses AI. Check for mistakes.

} else {
prevFlipRef.current.bt = false;
}
Expand Down Expand Up @@ -488,10 +487,9 @@ export default function useAlign(
nextOffsetY = tmpNextOffsetY;
popupOffsetY = -popupOffsetY;

nextAlignInfo.points = [
reversePoints(popupPoints, 0),
reversePoints(targetPoints, 0),
];
nextAlignInfo.points = nextAlignInfo.points.map((point) =>
reversePoints(splitPoints(point), 0),
);
} else {
prevFlipRef.current.tb = false;
}
Expand Down Expand Up @@ -541,10 +539,9 @@ export default function useAlign(
nextOffsetX = tmpNextOffsetX;
popupOffsetX = -popupOffsetX;

nextAlignInfo.points = [
reversePoints(popupPoints, 1),
reversePoints(targetPoints, 1),
];
nextAlignInfo.points = nextAlignInfo.points.map((point) =>
reversePoints(splitPoints(point), 1),
);
} else {
prevFlipRef.current.rl = false;
}
Expand Down Expand Up @@ -587,10 +584,9 @@ export default function useAlign(
nextOffsetX = tmpNextOffsetX;
popupOffsetX = -popupOffsetX;

nextAlignInfo.points = [
reversePoints(popupPoints, 1),
reversePoints(targetPoints, 1),
];
nextAlignInfo.points = nextAlignInfo.points.map((point) =>
reversePoints(splitPoints(point), 1),
);
} else {
prevFlipRef.current.lr = false;
}
Expand Down