Fix proposeDimensions error by checking terminal readiness first

Add isTerminalReady() check before calling fitAddon.proposeDimensions()
in the initial fit loop to prevent 'viewport.scrollBarWidth' TypeError
when terminal is not fully initialized.
This commit is contained in:
GitHub Copilot
2026-01-28 00:39:37 +00:00
parent a3b0d46fa8
commit 8ee6f2d605
6 changed files with 505 additions and 14775 deletions
+10
View File
@@ -353,6 +353,16 @@ class WebTerminal {
const maxAttempts = 120;
const attemptFitAndResize = (attempt: number) => {
// Check terminal readiness before calling proposeDimensions to avoid
// "viewport.scrollBarWidth" errors when terminal is not fully initialized
if (!this.isTerminalReady()) {
if (attempt < maxAttempts) {
window.requestAnimationFrame(() => attemptFitAndResize(attempt + 1));
return;
}
// Fall through to use fallback dimensions
}
const dims = (() => {
try {
return this.fitAddon.proposeDimensions();