Browse Source

Get byte index of last rune in textfield

Nick Van Dyck 7 years ago
parent
commit
83f152c406
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Terminal.Gui/Views/TextField.cs

+ 1 - 1
Terminal.Gui/Views/TextField.cs

@@ -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);