Update Dependencies (#390)

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/390
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
Norwin
2021-08-30 23:18:50 +08:00
committed by Andrew Thornton
parent 4b9907fb54
commit d6df0a53b5
665 changed files with 29466 additions and 24547 deletions

View File

@@ -6,7 +6,6 @@ import (
"strings"
"github.com/mattn/go-runewidth"
"github.com/muesli/reflow/ansi"
)
@@ -18,6 +17,7 @@ type Writer struct {
ansiWriter *ansi.Writer
buf bytes.Buffer
cache bytes.Buffer
lineLen int
ansi bool
}
@@ -48,7 +48,7 @@ func NewWriterPipe(forward io.Writer, width uint, paddingFunc PaddingFunc) *Writ
func Bytes(b []byte, width uint) []byte {
f := NewWriter(width, nil)
_, _ = f.Write(b)
f.Close()
_ = f.Flush()
return f.Bytes()
}
@@ -110,23 +110,34 @@ func (w *Writer) pad() error {
return nil
}
// Close will finish the padding operation. Always call it before trying to
// retrieve the final result.
func (w *Writer) Close() error {
// don't pad empty trailing lines
if w.lineLen == 0 {
return nil
}
return w.pad()
// Close will finish the padding operation.
func (w *Writer) Close() (err error) {
return w.Flush()
}
// Bytes returns the padded result as a byte slice.
func (w *Writer) Bytes() []byte {
return w.buf.Bytes()
return w.cache.Bytes()
}
// String returns the padded result as a string.
func (w *Writer) String() string {
return w.buf.String()
return w.cache.String()
}
// Flush will finish the padding operation. Always call it before trying to
// retrieve the final result.
func (w *Writer) Flush() (err error) {
if w.lineLen != 0 {
if err = w.pad(); err != nil {
return
}
}
w.cache.Reset()
_, err = w.buf.WriteTo(&w.cache)
w.lineLen = 0
w.ansi = false
return
}