Use DecodeCharacter over DecodeRune

This commit is contained in:
Zachary Yedidia
2020-05-20 16:43:12 -04:00
parent 65be5efd83
commit bdff221870
9 changed files with 106 additions and 33 deletions

View File

@@ -8,6 +8,7 @@ import (
"unicode/utf8"
"github.com/zyedidia/micro/v2/pkg/highlight"
"github.com/zyedidia/micro/v2/internal/util"
)
// Finds the byte index of the nth rune in a byte slice
@@ -19,7 +20,7 @@ func runeToByteIndex(n int, txt []byte) int {
count := 0
i := 0
for len(txt) > 0 {
_, size := utf8.DecodeRune(txt)
_, _, size := util.DecodeCharacter(txt)
txt = txt[size:]
count += size