diff options
| author | citrons <citrons@mondecitronne.com> | 2025-06-01 10:03:16 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-06-01 10:03:16 -0500 |
| commit | 6858497999286700603b8cf54741d13269e7736c (patch) | |
| tree | 3e63a6e0f70e5ee6d7d0531cab2178093b950784 /tui | |
| parent | f36a37c8e2acb91b69979f2f3d07b19f54725cca (diff) | |
fix line wrapping bug
Diffstat (limited to 'tui')
| -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]) { |
