diff options
| author | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-06-13 11:49:57 +0200 |
|---|---|---|
| committer | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-06-13 11:49:57 +0200 |
| commit | 79f30597d02950139c1ed24fe909192a6582fc84 (patch) | |
| tree | cb062f30663f127338f5596d8061cc79067b1d8f | |
| parent | Make renderedHeight correct (diff) | |
Fix word wrapping for 1-wide characters
Diffstat (limited to '')
| -rw-r--r-- | ui/ui.go | 39 |
1 files changed, 21 insertions, 18 deletions
@@ -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 { |
