浏览代码

Get byte index of last rune in textfield

Nick Van Dyck 7 年之前
父节点
当前提交
83f152c406
共有 1 个文件被更改,包括 1 次插入1 次删除
  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);