diff --git a/BeefLibs/Beefy2D/src/widgets/EditWidget.bf b/BeefLibs/Beefy2D/src/widgets/EditWidget.bf index 62c3bbae..f6f9ad78 100644 --- a/BeefLibs/Beefy2D/src/widgets/EditWidget.bf +++ b/BeefLibs/Beefy2D/src/widgets/EditWidget.bf @@ -2226,15 +2226,18 @@ namespace Beefy.widgets else if (lineIdx < GetLineCount() - 1) MoveCursorTo(lineIdx + 1, 0, false, 0, .SelectRight); - if (!mWidgetWindow.IsKeyDown(KeyCode.Control)) - break; - GetLineCharAtIdx(CursorTextPos, out lineIdx, out lineChar); anIndex = GetTextIdx(lineIdx, lineChar); if (anIndex == mData.mTextLength) break; char8 c = (char8)mData.mText[anIndex].mChar; + if ((uint8)c & 0xC0 == 0x80) + continue; + + if (!mWidgetWindow.IsKeyDown(KeyCode.Control)) + break; + CharType char8Type = GetCharType(c); if (char8Type == .Opening) break; diff --git a/BeefLibs/corlib/src/String.bf b/BeefLibs/corlib/src/String.bf index 339ccfba..04d3a8ec 100644 --- a/BeefLibs/corlib/src/String.bf +++ b/BeefLibs/corlib/src/String.bf @@ -359,6 +359,23 @@ namespace System } } + public int NumCodePoints + { + get + { + char8* ptr = Ptr; + + int count = 0; + for (int i < mLength) + { + char8 c = ptr[i]; + if (((uint8)c & 0xC0) != 0x80) + count++; + } + return count; + } + } + public int AllocSize { [Inline] @@ -3594,6 +3611,23 @@ namespace System } } + public int NumCodePoints + { + get + { + char8* ptr = Ptr; + + int count = 0; + for (int i < mLength) + { + char8 c = ptr[i]; + if (((uint8)c & 0xC0) != 0x80) + count++; + } + return count; + } + } + private int GetRangeStart(IndexRange range) { switch (range.Start) diff --git a/IDE/src/ui/SourceEditWidgetContent.bf b/IDE/src/ui/SourceEditWidgetContent.bf index 3552c9a6..6e4e0c4e 100644 --- a/IDE/src/ui/SourceEditWidgetContent.bf +++ b/IDE/src/ui/SourceEditWidgetContent.bf @@ -5366,7 +5366,7 @@ namespace IDE.ui String curLineStr = scope String(); GetLineText(line, curLineStr); - int32 lineEnd = (int32)curLineStr.Length; + int32 lineEnd = (int32)curLineStr.NumCodePoints; mVirtualCursorPos.ValueRef.mColumn = (.)Math.Min(mVirtualCursorPos.Value.mColumn, Math.Max(virtualEnd, lineEnd)); }