Skip to content
Snippets Groups Projects
Unverified Commit af809c96 authored by Junegunn Choi's avatar Junegunn Choi
Browse files

Minor refactorings

parent 329de8f4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment