Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vt/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func paramsString(cmd ansi.Cmd, params ansi.Params) string {
s.WriteByte(mark)
}
params.ForEach(-1, func(i, p int, more bool) {
s.WriteString(fmt.Sprintf("%d", p))
fmt.Fprintf(&s, "%d", p)
if i < len(params)-1 {
if more {
s.WriteByte(':')
Expand Down
32 changes: 17 additions & 15 deletions vt/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,31 +215,33 @@ func (e *Emulator) CursorPosition() uv.Position {

// Resize resizes the terminal.
func (e *Emulator) Resize(width int, height int) {
oldWidth := e.scr.Width()
x, y := e.scr.CursorPosition()

if e.atPhantom {
if x < width-1 {
e.atPhantom = false
x++
}
}

if y < 0 {
y = 0
}
if y >= height {
y = height - 1
}
if x < 0 {
x = 0
}
if x >= width {
x = width - 1
// If width changed and autowrap is enabled, use reflow for primary screen
if oldWidth != width && e.isModeSet(ansi.ModeAutoWrap) {
// Reflow primary screen with cursor tracking
result := e.scrs[0].Reflow(width, height, x, y)
x, y = result.CursorX, result.CursorY

// Alternate screen doesn't reflow (same as ghostty)
e.scrs[1].Resize(width, height)
} else {
// No reflow needed, just resize and clamp cursor
x = max(0, min(x, width-1))
y = max(0, min(y, height-1))
e.scrs[0].Resize(width, height)
e.scrs[1].Resize(width, height)
}

e.scrs[0].Resize(width, height)
e.scrs[1].Resize(width, height)
e.tabstops = uv.DefaultTabStops(width)

e.setCursor(x, y)

if e.isModeSet(ansi.ModeInBandResize) {
Expand Down Expand Up @@ -418,7 +420,7 @@ func (e *Emulator) IndexedColor(i int) color.Color {
c := e.colors[i]
if c == nil {
// Return the default color.
return ansi.IndexedColor(i) //nolint:gosec
return ansi.IndexedColor(uint8(i)) // #nosec G115 -- i is bounds-checked above (0-255)
}

return c
Expand Down
Loading
Loading