Skip to content

Commit

Permalink
Merge pull request #5311 from Susko3/fix-zero-width-textbox-throwing
Browse files Browse the repository at this point in the history
Fix zero width textbox throwing in `updateImeWindowPosition()`
  • Loading branch information
peppy authored Jul 18, 2022
2 parents 08c4006 + b076c04 commit 582170e
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit 582170e

Please sign in to comment.