mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-16 22:10:26 +00:00
parent
d087a890ba
commit
bde48c051a
1 changed files with 6 additions and 6 deletions
|
|
@ -11,12 +11,12 @@ import (
|
|||
// RunePos returns the rune index of a given byte index
|
||||
// This could cause problems if the byte index is between code points
|
||||
func runePos(p int, str string) int {
|
||||
// if p < 0 {
|
||||
// return -1
|
||||
// }
|
||||
// if p >= len(str) {
|
||||
// return -1
|
||||
// }
|
||||
if p < 0 {
|
||||
return 0
|
||||
}
|
||||
if p >= len(str) {
|
||||
return utf8.RuneCountInString(str)
|
||||
}
|
||||
return utf8.RuneCountInString(str[:p])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue