feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
committed by
GitHub
parent
b5015ec7b9
commit
447a51f08b
26
vendor/github.com/mitchellh/go-wordwrap/wordwrap.go
generated
vendored
26
vendor/github.com/mitchellh/go-wordwrap/wordwrap.go
generated
vendored
@@ -5,6 +5,8 @@ import (
|
||||
"unicode"
|
||||
)
|
||||
|
||||
const nbsp = 0xA0
|
||||
|
||||
// WrapString wraps the given string within lim width in characters.
|
||||
//
|
||||
// Wrapping is currently naive and only happens at white-space. A future
|
||||
@@ -18,50 +20,58 @@ func WrapString(s string, lim uint) string {
|
||||
|
||||
var current uint
|
||||
var wordBuf, spaceBuf bytes.Buffer
|
||||
var wordBufLen, spaceBufLen uint
|
||||
|
||||
for _, char := range s {
|
||||
if char == '\n' {
|
||||
if wordBuf.Len() == 0 {
|
||||
if current+uint(spaceBuf.Len()) > lim {
|
||||
if current+spaceBufLen > lim {
|
||||
current = 0
|
||||
} else {
|
||||
current += uint(spaceBuf.Len())
|
||||
current += spaceBufLen
|
||||
spaceBuf.WriteTo(buf)
|
||||
}
|
||||
spaceBuf.Reset()
|
||||
spaceBufLen = 0
|
||||
} else {
|
||||
current += uint(spaceBuf.Len() + wordBuf.Len())
|
||||
current += spaceBufLen + wordBufLen
|
||||
spaceBuf.WriteTo(buf)
|
||||
spaceBuf.Reset()
|
||||
spaceBufLen = 0
|
||||
wordBuf.WriteTo(buf)
|
||||
wordBuf.Reset()
|
||||
wordBufLen = 0
|
||||
}
|
||||
buf.WriteRune(char)
|
||||
current = 0
|
||||
} else if unicode.IsSpace(char) {
|
||||
} else if unicode.IsSpace(char) && char != nbsp {
|
||||
if spaceBuf.Len() == 0 || wordBuf.Len() > 0 {
|
||||
current += uint(spaceBuf.Len() + wordBuf.Len())
|
||||
current += spaceBufLen + wordBufLen
|
||||
spaceBuf.WriteTo(buf)
|
||||
spaceBuf.Reset()
|
||||
spaceBufLen = 0
|
||||
wordBuf.WriteTo(buf)
|
||||
wordBuf.Reset()
|
||||
wordBufLen = 0
|
||||
}
|
||||
|
||||
spaceBuf.WriteRune(char)
|
||||
spaceBufLen++
|
||||
} else {
|
||||
|
||||
wordBuf.WriteRune(char)
|
||||
wordBufLen++
|
||||
|
||||
if current+uint(spaceBuf.Len()+wordBuf.Len()) > lim && uint(wordBuf.Len()) < lim {
|
||||
if current+wordBufLen+spaceBufLen > lim && wordBufLen < lim {
|
||||
buf.WriteRune('\n')
|
||||
current = 0
|
||||
spaceBuf.Reset()
|
||||
spaceBufLen = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if wordBuf.Len() == 0 {
|
||||
if current+uint(spaceBuf.Len()) <= lim {
|
||||
if current+spaceBufLen <= lim {
|
||||
spaceBuf.WriteTo(buf)
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user