Browse Source
Fix broken pre-edit markedText on iOS and solve #17523 (#17618 )
* fix: add missing ref keyword to CombinedSpan3.CopyFromSpan
* fix: fix incorrect indent in IUITextInput.TextInRange and boundary condition for surroundingText
---------
Co-authored-by: Max Katz <maxkatz6@outlook.com>
pull/17682/head
MizuKuma
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
7 additions and
5 deletions
src/iOS/Avalonia.iOS/CombinedSpan3.cs
src/iOS/Avalonia.iOS/TextInputResponder.cs
@ -16,7 +16,7 @@ internal ref struct CombinedSpan3<T>
public int Length = > Span1 . Length + Span2 . Length + Span3 . Length ;
static void CopyFromSpan ( ReadOnlySpan < T > from , int offset , ref Span < T > to )
static void CopyFromSpan ( ReadOnlySpan < T > from , ref int offset , ref Span < T > to )
{
if ( to . Length = = 0 )
return ;
@ -33,8 +33,8 @@ internal ref struct CombinedSpan3<T>
public void CopyTo ( Span < T > to , int offset )
{
CopyFromSpan ( Span1 , offset , ref to ) ;
CopyFromSpan ( Span2 , offset , ref to ) ;
CopyFromSpan ( Span3 , offset , ref to ) ;
CopyFromSpan ( Span1 , ref offset , ref to ) ;
CopyFromSpan ( Span2 , ref offset , ref to ) ;
CopyFromSpan ( Span3 , ref offset , ref to ) ;
}
}
@ -220,15 +220,17 @@ partial class AvaloniaView
string result = "" ;
if ( string . IsNullOrEmpty ( _ markedText ) )
{
if ( surroundingText ! = null & & r . EndIndex < surroundingText . Length )
{
result = surroundingText [ r . StartIndex . . r . EndIndex ] ;
}
}
else
{
var span = new CombinedSpan3 < char > ( surroundingText . AsSpan ( ) . Slice ( 0 , currentSelection . Start ) ,
_ markedText ,
surroundingText . AsSpan ( ) . Slice ( currentSelection . Start ) ) ;
surroundingText . AsSpan ( ) . Slice ( currentSelection . Start , currentSelection . End - currentSelection . Start ) ) ;
var buf = new char [ r . EndIndex - r . StartIndex ] ;
span . CopyTo ( buf , r . StartIndex ) ;
result = new string ( buf ) ;