Explorar o código

Merge pull request #94 from nickvdyck/last-rune-index

Get byte index of last rune in textfield
Miguel de Icaza %!s(int64=7) %!d(string=hai) anos
pai
achega
8b884efca0
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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);