Minor refactorings

pull/1029/head
Junegunn Choi 7 years ago
parent 329de8f416
commit af809c9661
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -79,7 +79,7 @@ func extractColor(str string, state *ansiState, proc func(string, *ansiState) bo
// Make sure that we found an ANSI code
offset := ansiRegex.FindStringIndex(str[idx:])
if offset == nil {
if len(offset) < 2 {
idx++
continue
}

@ -76,7 +76,7 @@ func (r *Reader) feed(src io.Reader) {
// end in delim.
bytea, err := reader.ReadBytes(delim)
byteaLen := len(bytea)
if len(bytea) > 0 {
if byteaLen > 0 {
if err == nil {
// get rid of carriage return if under Windows:
if util.IsWindows() && byteaLen >= 2 && bytea[byteaLen-2] == byte('\r') {

@ -147,7 +147,7 @@ func Tokenize(text string, delimiter Delimiter) []Token {
if delimiter.regex != nil {
for len(text) > 0 {
loc := delimiter.regex.FindStringIndex(text)
if loc == nil {
if len(loc) < 2 {
loc = []int{0, len(text)}
}
last := util.Max(loc[1], 1)

@ -160,7 +160,7 @@ func (chars *Chars) CopyRunes(dest []rune) {
copy(dest, runes)
return
}
for idx, b := range chars.slice {
for idx, b := range chars.slice[:len(dest)] {
dest[idx] = rune(b)
}
return

Loading…
Cancel
Save