diff options
| -rw-r--r-- | tui/layout.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tui/layout.go b/tui/layout.go index e2c3e0f..1413243 100644 --- a/tui/layout.go +++ b/tui/layout.go @@ -191,13 +191,15 @@ func (b *Box) computeText(axis int) { for _, t := range b.text { g := uniseg.NewGraphemes(t.text) for g.Next() { - line += g.Width() - if g.LineBreak() == uniseg.LineMustBreak { + if g.Str() == "\n" { maxLine = max(maxLine, line) line = 0 + } else { + line += g.Width() } } } + maxLine = max(maxLine, line) if b.Width == TextSize { b.computedSize[axis] = maxLine + b.marginsSize(axis) } @@ -216,7 +218,7 @@ func (b *Box) computeText(axis int) { word.add(g.Str(), run.style) if word.width >= limit { line.addRuns(word.flush()) - } else if line.width + word.width >= limit { + } else if line.width + word.width > limit { b.computedLines = append(b.computedLines, line.flush()) } if unicode.IsSpace(g.Runes()[0]) { |
