fix drawing of wide characters in InfoWindow (#3919)

This commit is contained in:
Mikko
2025-11-27 20:45:30 +02:00
committed by GitHub
parent a2620d1c02
commit 70dfc7fcb4

View File

@@ -122,16 +122,8 @@ func (i *InfoWindow) displayBuffer() {
} }
rw := runewidth.RuneWidth(r) screen.SetContent(vlocX, i.Y, r, combc, style)
for j := 0; j < rw; j++ { vlocX += runewidth.RuneWidth(r)
c := r
if j > 0 {
c = ' '
combc = nil
}
screen.SetContent(vlocX, i.Y, c, combc, style)
}
vlocX++
} }
nColsBeforeStart-- nColsBeforeStart--
} }
@@ -142,29 +134,22 @@ func (i *InfoWindow) displayBuffer() {
curBX := blocX curBX := blocX
r, combc, size := util.DecodeCharacter(line) r, combc, size := util.DecodeCharacter(line)
draw(r, combc, i.defStyle())
width := 0 width := 0
char := ' '
switch r { switch r {
case '\t': case '\t':
ts := tabsize - (totalwidth % tabsize) width = tabsize - (totalwidth % tabsize)
width = ts for j := 0; j < width; j++ {
draw(' ', nil, i.defStyle())
}
default: default:
width = runewidth.RuneWidth(r) width = runewidth.RuneWidth(r)
char = '@' draw(r, combc, i.defStyle())
} }
blocX++ blocX++
line = line[size:] line = line[size:]
// Draw any extra characters either spaces for tabs or @ for incomplete wide runes
if width > 1 {
for j := 1; j < width; j++ {
draw(char, nil, i.defStyle())
}
}
if activeC.X == curBX { if activeC.X == curBX {
screen.ShowCursor(curVX, i.Y) screen.ShowCursor(curVX, i.Y)
} }