fix: send the first pty size immediately, debounce only subsequent resizes
This commit is contained in:
1 parent
ce89dcb1e4
commit
f63ee379a4
1 file changed
+11
-3
@@ -348,17 +348,25 @@ export const TerminalView: ForwardRefExoticComponent<TerminalViewProps & { ref?:
|
|||||||
// The xterm grid is already correct; only tell the pty once it settles.
|
// The xterm grid is already correct; only tell the pty once it settles.
|
||||||
const last = ptySizeRef.current
|
const last = ptySizeRef.current
|
||||||
if (last && last.cols === term.cols && last.rows === term.rows) return
|
if (last && last.cols === term.cols && last.rows === term.rows) return
|
||||||
window.clearTimeout(ptyTimerRef.current)
|
const send = (): void => {
|
||||||
ptyTimerRef.current = window.setTimeout(() => {
|
|
||||||
const live = termRef.current
|
const live = termRef.current
|
||||||
if (!live || deadRef.current) return
|
if (!live || deadRef.current) return
|
||||||
if (live.cols === ptySizeRef.current?.cols && live.rows === ptySizeRef.current?.rows) return
|
if (live.cols === ptySizeRef.current?.cols && live.rows === ptySizeRef.current?.rows) return
|
||||||
ptySizeRef.current = { cols: live.cols, rows: live.rows }
|
ptySizeRef.current = { cols: live.cols, rows: live.rows }
|
||||||
window.api.resizePty(sessionId, live.cols, live.rows)
|
window.api.resizePty(sessionId, live.cols, live.rows)
|
||||||
|
}
|
||||||
|
window.clearTimeout(ptyTimerRef.current)
|
||||||
|
// First size for a session goes out immediately (the pty spawns at a
|
||||||
|
// placeholder 80x24 and a shell may already be drawing); later changes —
|
||||||
|
// window drags, maximize/restore — wait for the layout to settle.
|
||||||
|
if (!last) {
|
||||||
|
send()
|
||||||
|
return
|
||||||
|
}
|
||||||
// 100ms mirrors what other Electron terminals use: long enough to swallow
|
// 100ms mirrors what other Electron terminals use: long enough to swallow
|
||||||
// a maximize/restore animation tick storm, short enough that a plain
|
// a maximize/restore animation tick storm, short enough that a plain
|
||||||
// window drag does not visibly wrap against a stale width.
|
// window drag does not visibly wrap against a stale width.
|
||||||
}, 100)
|
ptyTimerRef.current = window.setTimeout(send, 100)
|
||||||
})
|
})
|
||||||
}, [sessionId])
|
}, [sessionId])
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user