Browse Source

Don't throw on unexpected iOS input (#20728)

* Don't throw on unexpected iOS input

* Improve normalization
pull/14481/merge
kerams 3 weeks ago
committed by GitHub
parent
commit
dafa53a49c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 27
      src/iOS/Avalonia.iOS/TextInputResponder.cs

27
src/iOS/Avalonia.iOS/TextInputResponder.cs

@ -34,14 +34,10 @@ partial class AvaloniaView
public AvaloniaTextRange(int startIndex, int endIndex)
{
if (startIndex < 0)
throw new ArgumentOutOfRangeException(nameof(startIndex));
if (endIndex < startIndex)
throw new ArgumentOutOfRangeException(nameof(endIndex));
StartIndex = startIndex;
EndIndex = endIndex;
var a = Math.Max(0, startIndex);
var b = Math.Max(0, endIndex);
StartIndex = Math.Min(a, b);
EndIndex = Math.Max(a, b);
}
public override bool IsEmpty => StartIndex == EndIndex;
@ -58,9 +54,7 @@ partial class AvaloniaView
{
public AvaloniaTextPosition(int index)
{
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
Index = index;
Index = Math.Max(0, index);
}
public int Index { get; }
@ -509,14 +503,15 @@ partial class AvaloniaView
{
if (_inSurroundingTextUpdateEvent > 0)
return;
if (value == null)
_client.Selection = default;
else
{
var r = (AvaloniaTextRange)value;
if (value is AvaloniaTextRange r)
{
_client.Selection = new TextSelection(r.StartIndex, r.EndIndex);
}
else
{
_client.Selection = default;
}
}
}

Loading…
Cancel
Save