summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtzfr.eu>2020-06-13 11:49:57 +0200
committerHubert Hirtz <hubert@hirtzfr.eu>2020-06-13 11:49:57 +0200
commit79f30597d02950139c1ed24fe909192a6582fc84 (patch)
treecb062f30663f127338f5596d8061cc79067b1d8f
parentMake renderedHeight correct (diff)
Fix word wrapping for 1-wide characters
Diffstat (limited to '')
-rw-r--r--ui/ui.go39
1 files changed, 21 insertions, 18 deletions
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 {