fix(vt): home scroll margins inside origin mode
- commit
- 532e4e5de12514ec512800909910b6f04eae351b
- author
- brice · · 2026-07-09 14:23 UTC
- parent
- b34df7b
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +20 -1
M pkg/vt/screen.go +1 -1
| @@ -1135,7 +1135,7 @@ func (s *Screen) setScrollRegion(parts []int) { | |||
| 1135 | 1135 | s.resetScrollRegion() | |
| 1136 | 1136 | } | |
| 1137 | 1137 | } | |
| 1138 | - | s.Row, s.Col = 0, 0 | |
| 1138 | + | s.homeCursor() | |
| 1139 | 1139 | } | |
| 1140 | 1140 | ||
| 1141 | 1141 | func (s *Screen) resetScrollRegion() { | |
| @@ -1135,7 +1135,7 @@ func (s *Screen) setScrollRegion(parts []int) { | |||||
| 1135 | s.resetScrollRegion() | 1135 | s.resetScrollRegion() | ||
| 1136 | } | 1136 | } | ||
| 1137 | } | 1137 | } | ||
| 1138 | - | s.Row, s.Col = 0, 0 | 1138 | + | s.homeCursor() |
| 1139 | } | 1139 | } | ||
| 1140 | 1140 | ||||
| 1141 | func (s *Screen) resetScrollRegion() { | 1141 | func (s *Screen) resetScrollRegion() { | ||
M pkg/vt/screen_test.go +19 -0
| @@ -1316,6 +1316,25 @@ func TestCSIEditingSequences(t *testing.T) { | |||
| 1316 | 1316 | } | |
| 1317 | 1317 | }, | |
| 1318 | 1318 | }, | |
| 1319 | + | { | |
| 1320 | + | name: "DECOM already set homes DECSTBM to scroll region", | |
| 1321 | + | run: func(t *testing.T) { | |
| 1322 | + | s := NewScreen(6, 5) | |
| 1323 | + | s.Write([]byte("\x1b[?6h\x1b[2;4r")) | |
| 1324 | + | if s.Row != 1 || s.Col != 0 { | |
| 1325 | + | t.Fatalf("DECSTBM cursor with DECOM set = (%d,%d), want (1,0)", s.Row, s.Col) | |
| 1326 | + | } | |
| 1327 | + | ||
| 1328 | + | s.Write([]byte("\x1b[2;3H")) | |
| 1329 | + | if s.Row != 2 || s.Col != 2 { | |
| 1330 | + | t.Fatalf("DECOM addressed cursor after DECSTBM = (%d,%d), want (2,2)", s.Row, s.Col) | |
| 1331 | + | } | |
| 1332 | + | s.Write([]byte("\x1b[99;1H")) | |
| 1333 | + | if s.Row != 3 || s.Col != 0 { | |
| 1334 | + | t.Fatalf("DECOM clamped cursor after DECSTBM = (%d,%d), want (3,0)", s.Row, s.Col) | |
| 1335 | + | } | |
| 1336 | + | }, | |
| 1337 | + | }, | |
| 1319 | 1338 | { | |
| 1320 | 1339 | name: "DECOM reset homes and restores full-frame addressing", | |
| 1321 | 1340 | run: func(t *testing.T) { | |
| @@ -1316,6 +1316,25 @@ func TestCSIEditingSequences(t *testing.T) { | |||||
| 1316 | } | 1316 | } | ||
| 1317 | }, | 1317 | }, | ||
| 1318 | }, | 1318 | }, | ||
| 1319 | + | { | |||
| 1320 | + | name: "DECOM already set homes DECSTBM to scroll region", | |||
| 1321 | + | run: func(t *testing.T) { | |||
| 1322 | + | s := NewScreen(6, 5) | |||
| 1323 | + | s.Write([]byte("\x1b[?6h\x1b[2;4r")) | |||
| 1324 | + | if s.Row != 1 || s.Col != 0 { | |||
| 1325 | + | t.Fatalf("DECSTBM cursor with DECOM set = (%d,%d), want (1,0)", s.Row, s.Col) | |||
| 1326 | + | } | |||
| 1327 | + | ||||
| 1328 | + | s.Write([]byte("\x1b[2;3H")) | |||
| 1329 | + | if s.Row != 2 || s.Col != 2 { | |||
| 1330 | + | t.Fatalf("DECOM addressed cursor after DECSTBM = (%d,%d), want (2,2)", s.Row, s.Col) | |||
| 1331 | + | } | |||
| 1332 | + | s.Write([]byte("\x1b[99;1H")) | |||
| 1333 | + | if s.Row != 3 || s.Col != 0 { | |||
| 1334 | + | t.Fatalf("DECOM clamped cursor after DECSTBM = (%d,%d), want (3,0)", s.Row, s.Col) | |||
| 1335 | + | } | |||
| 1336 | + | }, | |||
| 1337 | + | }, | |||
| 1319 | { | 1338 | { | ||
| 1320 | name: "DECOM reset homes and restores full-frame addressing", | 1339 | name: "DECOM reset homes and restores full-frame addressing", | ||
| 1321 | run: func(t *testing.T) { | 1340 | run: func(t *testing.T) { | ||