Skip to content

Commit d3a071c

Browse files
nk-batman21gdamore
authored andcommitted
fix(vt): reset grapheme state after resizing
1 parent bb0324d commit d3a071c

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎vt/emulate.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,6 +2395,7 @@ func (em *emulator) ResizeEvent(size Coord) {
23952395

23962396
func (em *emulator) applyResize(size Coord) {
23972397
// resize clobbers our content, until it is redrawn
2398+
em.lastIndex = 0
23982399
em.size = size
23992400
em.tabStops = slices.DeleteFunc(em.tabStops, func(x Col) bool { return x >= em.size.X })
24002401
// resizing resets the margins

‎vt/tests/mock_test.go‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,28 @@ func TestBackendBlitReverse(t *testing.T) {
12601260
CheckAttrs(t, term, 2, 2, vt.Bold)
12611261
}
12621262

1263+
func TestGraphemeClusterAfterResize(t *testing.T) {
1264+
for _, tc := range []struct {
1265+
name string
1266+
size, cell, cursor Coord
1267+
}{
1268+
{"shrink", Coord{X: 4, Y: 2}, Coord{X: 3, Y: 1}, Coord{X: 3, Y: 1}},
1269+
{"grow", Coord{X: 16, Y: 8}, Coord{X: 7, Y: 3}, Coord{X: 8, Y: 3}},
1270+
} {
1271+
t.Run(tc.name, func(t *testing.T) {
1272+
term := vt.NewMockTerm(vt.MockOptSize{X: 8, Y: 4})
1273+
defer MustClose(t, term)
1274+
MustStart(t, term)
1275+
1276+
WriteF(t, term, "\x1b[?2027h\x1b[4;7He")
1277+
term.SetSize(tc.size)
1278+
WriteF(t, term, "x\u0301")
1279+
CheckContent(t, term, tc.cell.X, tc.cell.Y, "x\u0301")
1280+
CheckPos(t, term, tc.cursor.X, tc.cursor.Y)
1281+
})
1282+
}
1283+
}
1284+
12631285
func TestGraphemeCluster(t *testing.T) {
12641286
term := vt.NewMockTerm(vt.MockOptSize{X: 10, Y: 5})
12651287
defer MustClose(t, term)

0 commit comments

Comments
 (0)