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

Fix zero width textbox throwing in updateImeWindowPosition() #5311

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Changes from 1 commit
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
13 changes: 11 additions & 2 deletions osu.Framework/Graphics/UserInterface/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1570,8 +1570,17 @@ private void updateImeWindowPosition()
float start = getPositionAt(startIndex) - textContainerPosX + LeftRightPadding;
float end = getPositionAt(endIndex) - textContainerPosX + LeftRightPadding;

start = Math.Clamp(start, LeftRightPadding, DrawWidth - LeftRightPadding);
end = Math.Clamp(end, LeftRightPadding, DrawWidth - LeftRightPadding);
if (LeftRightPadding <= DrawWidth - LeftRightPadding)
{
start = Math.Clamp(start, LeftRightPadding, DrawWidth - LeftRightPadding);
end = Math.Clamp(end, LeftRightPadding, DrawWidth - LeftRightPadding);
}
else
{
// DrawWidth is probably zero/invalid, sane fallback instead of throwing in Math.Clamp
start = 0;
end = 0;
}

var compositionTextRectangle = new RectangleF
{
Expand Down