Browse Source

fix 12161

pull/12171/head
startewho 3 years ago
parent
commit
aa7a2a2764
  1. 22
      src/Avalonia.Controls/Utils/StringUtils.cs

22
src/Avalonia.Controls/Utils/StringUtils.cs

@ -76,7 +76,7 @@ namespace Avalonia.Controls.Utils
}
var codepoint = new Codepoint(text[index]);
if (!codepoint.IsWhiteSpace)
{
return false;
@ -85,12 +85,16 @@ namespace Avalonia.Controls.Utils
// preceeded by lwsp.
if (index > 0)
{
var nextCodePoint = new Codepoint(text[index + 1]);
if (nextCodePoint.IsBreakChar)
if (index + 1 < text.Length)
{
return true;
var nextCodePoint = new Codepoint(text[index + 1]);
if (nextCodePoint.IsBreakChar)
{
return true;
}
}
return true;
}
switch (codepoint.GeneralCategory)
@ -125,7 +129,7 @@ namespace Avalonia.Controls.Utils
}
cursor = Math.Min(cursor, text.Length);
int begin;
int i;
int cr;
@ -181,7 +185,7 @@ namespace Avalonia.Controls.Utils
{
return cursor;
}
if (cr < text.Length && text[cr] == '\r' && cr + 1 < text.Length && text[cr + 1] == '\n')
{
lf = cr + 1;
@ -214,9 +218,9 @@ namespace Avalonia.Controls.Utils
{
return i;
}
var cc = GetCharClass(text[i]);
// skip over the word, punctuation, or run of whitespace
while (i < cr && GetCharClass(text[i]) == cc)
{

Loading…
Cancel
Save