Get byte index of last rune in textfield

This commit is contained in:
Nick Van Dyck
2018-05-18 12:12:03 +02:00
parent 2af83a14cc
commit 83f152c406

View File

@@ -176,7 +176,7 @@ namespace Terminal.Gui {
int RuneIndexToByteIndex (int index)
{
var blen = text.Length;
for (int byteIndex = 0, runeIndex = 0; byteIndex < blen; runeIndex++) {
for (int byteIndex = 0, runeIndex = 0; byteIndex <= blen; runeIndex++) {
if (index == runeIndex)
return byteIndex;
(var rune, var size) = Utf8.DecodeRune (text, byteIndex, byteIndex - blen);