Browse Source
Merge pull request #12322 from Gillibald/fixes/getCharacterHitFromDistance
Adjust GetCharacterHitFromDistance to match what WPF expects
release/11.0.1
Dan Walmsley
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
3 additions and
3 deletions
-
src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs
-
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs
|
|
|
@ -204,7 +204,7 @@ namespace Avalonia.Media.TextFormatting |
|
|
|
|
|
|
|
if (_paragraphProperties.FlowDirection == FlowDirection.RightToLeft) |
|
|
|
{ |
|
|
|
currentPosition = Length - firstRun.Length; |
|
|
|
currentPosition += lineLength - firstRun.Length; |
|
|
|
} |
|
|
|
|
|
|
|
return GetRunCharacterHit(firstRun, currentPosition, 0); |
|
|
|
@ -216,7 +216,7 @@ namespace Avalonia.Media.TextFormatting |
|
|
|
|
|
|
|
if (_paragraphProperties.FlowDirection == FlowDirection.LeftToRight) |
|
|
|
{ |
|
|
|
currentPosition = FirstTextSourceIndex + Length - lastRun.Length; |
|
|
|
currentPosition += lineLength - lastRun.Length; |
|
|
|
} |
|
|
|
|
|
|
|
return GetRunCharacterHit(lastRun, currentPosition, distance); |
|
|
|
|
|
|
|
@ -713,7 +713,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting |
|
|
|
|
|
|
|
var characterHit = textLine.GetCharacterHitFromDistance(1000); |
|
|
|
|
|
|
|
Assert.Equal(11, characterHit.FirstCharacterIndex); |
|
|
|
Assert.Equal(10, characterHit.FirstCharacterIndex); |
|
|
|
Assert.Equal(1, characterHit.TrailingLength); |
|
|
|
} |
|
|
|
} |
|
|
|
|