Skip to content

Commit

Permalink
fix: long lines in System Info pane
Browse files Browse the repository at this point in the history
use unconditional wrap when wordwrap doesn't work
  • Loading branch information
jm33-m0 committed Jan 30, 2024
1 parent 45d0ff7 commit ef6f1d9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion core/lib/util/str.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/google/uuid"
"github.com/muesli/reflow/wordwrap"
"github.com/muesli/reflow/wrap"
)

// ParseCmd parse commands containing whitespace
Expand Down Expand Up @@ -71,7 +72,19 @@ func ReverseString(s string) string {

// Split long lines
func SplitLongLine(line string, linelen int) (ret string) {
return wordwrap.String(line, linelen)
ret = wordwrap.String(line, linelen)

// if any of the wrapped lines are still too long
// use unconditional wrap
lines := strings.Split(ret, "\n")
for _, wline := range lines {
line_len := len(wline)
if line_len > linelen {
ret = wrap.String(line, linelen)
break
}
}
return
}

// RandInt random int between given interval
Expand Down

0 comments on commit ef6f1d9

Please sign in to comment.