Use strings.ContainsRune instead (#3335)

This commit is contained in:
guangwu 2023-06-17 18:10:12 +08:00 committed by GitHub
parent d471067e3f
commit 4772bd8d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -221,9 +221,9 @@ func charClassOfAscii(char rune) charClass {
return charUpper return charUpper
} else if char >= '0' && char <= '9' { } else if char >= '0' && char <= '9' {
return charNumber return charNumber
} else if strings.IndexRune(whiteChars, char) >= 0 { } else if strings.ContainsRune(whiteChars, char) {
return charWhite return charWhite
} else if strings.IndexRune(delimiterChars, char) >= 0 { } else if strings.ContainsRune(delimiterChars, char) {
return charDelimiter return charDelimiter
} }
return charNonWord return charNonWord
@ -240,7 +240,7 @@ func charClassOfNonAscii(char rune) charClass {
return charLetter return charLetter
} else if unicode.IsSpace(char) { } else if unicode.IsSpace(char) {
return charWhite return charWhite
} else if strings.IndexRune(delimiterChars, char) >= 0 { } else if strings.ContainsRune(delimiterChars, char) {
return charDelimiter return charDelimiter
} }
return charNonWord return charNonWord

View File

@ -763,7 +763,7 @@ func (t *Terminal) ansiLabelPrinter(str string, color *tui.ColorPair, fill bool)
runes := []rune(text) runes := []rune(text)
// Simpler printer for strings without ANSI colors or tab characters // Simpler printer for strings without ANSI colors or tab characters
if colors == nil && strings.IndexRune(str, '\t') < 0 { if colors == nil && !strings.ContainsRune(str, '\t') {
length := util.StringWidth(str) length := util.StringWidth(str)
if length == 0 { if length == 0 {
return nil, 0 return nil, 0