diff --git a/src/croc/croc.go b/src/croc/croc.go index a10b70b..0a3555f 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -19,6 +19,7 @@ import ( "sync" "time" + "golang.org/x/term" "golang.org/x/time/rate" "github.com/denisbrodbeck/machineid" @@ -1735,8 +1736,9 @@ func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error) } else { description = " " + description } - if len(description) > 20 { - description = description[:17] + "..." + width, _, err := term.GetSize(int(os.Stdout.Fd())) + if len(description) > width { + description = description[:(width-3)] + "..." } c.bar = progressbar.NewOptions64(1, progressbar.OptionOnCompletion(func() { @@ -1914,8 +1916,10 @@ func (c *Client) setBar() { } else if !c.Options.IsSender { description = " " + description } - if len(description) > 20 { - description = description[:17] + "..." + width, _, _ := term.GetSize(int(os.Stdout.Fd())) + description = strings.TrimSpace(description) + if len(description) > width { + description = description[:(width-3)] + "..." } c.bar = progressbar.NewOptions64( c.FilesToTransfer[c.FilesToTransferCurrentNum].Size,