Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit b260567

Browse files
Merge pull request #362 from FrozenAssassine/fixfor#356
This fixes #356
2 parents 8466f6d + 3046daf commit b260567

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

TextControlBox/Renderer/SelectionRenderer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,18 @@ public TextSelection DrawSelection(CanvasTextLayout TextLayout, IEnumerable<stri
101101
}
102102

103103
SelectionStart = Math.Min(SelStartIndex, SelEndIndex);
104+
105+
if (SelectionStart < 0)
106+
SelectionStart = 0;
107+
if (SelectionLength < 0)
108+
SelectionLength = 0;
104109

105110
if (SelEndIndex > SelStartIndex)
106111
SelectionLength = SelEndIndex - SelStartIndex;
107112
else
108113
SelectionLength = SelStartIndex - SelEndIndex;
109114

115+
Debug.WriteLine("SELSTART: " + SelectionStart);
110116
CanvasTextLayoutRegion[] descriptions = TextLayout.GetCharacterRegions(SelectionStart, SelectionLength);
111117
for (int i = 0; i < descriptions.Length; i++)
112118
{

TextControlBox/Text/CursorPosition.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ internal void AddToCharacterPos(int Add)
2929
internal void SubtractFromCharacterPos(int Value)
3030
{
3131
CharacterPosition -= Value;
32+
if (CharacterPosition < 0)
33+
CharacterPosition = 0;
3234
}
3335
internal new string ToString()
3436
{

0 commit comments

Comments
 (0)