diff --git a/osu.Framework/Graphics/UserInterface/TextBox.cs b/osu.Framework/Graphics/UserInterface/TextBox.cs index ad4142618a..6e2a9cfbe3 100644 --- a/osu.Framework/Graphics/UserInterface/TextBox.cs +++ b/osu.Framework/Graphics/UserInterface/TextBox.cs @@ -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 {