From 79f30597d02950139c1ed24fe909192a6582fc84 Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Sat, 13 Jun 2020 11:49:57 +0200 Subject: Fix word wrapping for 1-wide characters --- ui/ui.go | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'ui/ui.go') diff --git a/ui/ui.go b/ui/ui.go index cb5b7db..99a44d3 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -290,29 +290,32 @@ func (ui *UI) drawBuffer() { rs := []rune(line.Content) x := 0 y := y0 + var lastSP Point spIdx := 0 - hasLineHadSplit := false for i, r := range rs { - if hasLineHadSplit && (y-y0+1)*w <= line.SplitPoints[spIdx].X { - y++ - x = 0 - hasLineHadSplit = false - } else if w <= x { + if i == line.SplitPoints[spIdx].I { + lastSP = line.SplitPoints[spIdx] + spIdx++ + + l := line.SplitPoints[spIdx].X - lastSP.X + + if w < l { + } else if w == l { + if x == 0 { + y++ + } + } else if w < x+l { + y++ + x = 0 + } + } + if !line.SplitPoints[spIdx].Split && x == 0 { + continue + } + if w <= x { y++ x = 0 - hasLineHadSplit = false - } - - if line.SplitPoints[spIdx].Split { - if i == line.SplitPoints[spIdx].I { - spIdx++ - } - if x == 0 { - continue - } - - hasLineHadSplit = true } if colorState == 1 { -- cgit v1.2.3