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