commit 79f3059
Hubert Hirtz
·
2020-06-13 09:49:57 +0000 UTC
parent a4fd300
Fix word wrapping for 1-wide characters
1 files changed,
+21,
-18
M
ui/ui.go
M
ui/ui.go
+21,
-18
1@@ -290,29 +290,32 @@ func (ui *UI) drawBuffer() {
2 rs := []rune(line.Content)
3 x := 0
4 y := y0
5+ var lastSP Point
6 spIdx := 0
7- hasLineHadSplit := false
8
9 for i, r := range rs {
10- if hasLineHadSplit && (y-y0+1)*w <= line.SplitPoints[spIdx].X {
11- y++
12- x = 0
13- hasLineHadSplit = false
14- } else if w <= x {
15+ if i == line.SplitPoints[spIdx].I {
16+ lastSP = line.SplitPoints[spIdx]
17+ spIdx++
18+
19+ l := line.SplitPoints[spIdx].X - lastSP.X
20+
21+ if w < l {
22+ } else if w == l {
23+ if x == 0 {
24+ y++
25+ }
26+ } else if w < x+l {
27+ y++
28+ x = 0
29+ }
30+ }
31+ if !line.SplitPoints[spIdx].Split && x == 0 {
32+ continue
33+ }
34+ if w <= x {
35 y++
36 x = 0
37- hasLineHadSplit = false
38- }
39-
40- if line.SplitPoints[spIdx].Split {
41- if i == line.SplitPoints[spIdx].I {
42- spIdx++
43- }
44- if x == 0 {
45- continue
46- }
47-
48- hasLineHadSplit = true
49 }
50
51 if colorState == 1 {