Skip to content

Commit 607af1a

Browse files
committed
More debugging messages
1 parent 094ffd9 commit 607af1a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ async function createTerminal(element: HTMLElement, toDispose: DisposableCollect
140140
} as ITerminalOptions);
141141
toDispose.push(term);
142142

143-
window.term = term; // Expose `term` to window for debugging purposes
143+
window.terminal = term;
144144
term.onResize(async (size) => {
145145
await resizeRemoteTerminal(size, pid);
146+
console.info(`Resized remote terminal to ${size.cols}x${size.rows}`);
146147
});
147148
protocol = location.protocol === "https:" ? "wss://" : "ws://";
148149
socketURL = `${protocol + location.hostname + (location.port ? ":" + location.port : "")
@@ -228,8 +229,12 @@ async function runRealTerminal(terminal: Terminal, socket: WebSocket): Promise<v
228229
}
229230

230231
function updateTerminalSize(): void {
232+
if (!window.terminal) {
233+
console.warn("Terminal not yet initialized. Aborting resize.");
234+
return;
235+
}
231236
const fitAddon = new FitAddon();
232-
term.loadAddon(fitAddon);
237+
window.terminal.loadAddon(fitAddon);
233238
fitAddon.fit();
234239
}
235240

src/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import ReconnectingWebSocket from 'reconnecting-websocket';
1010
export type AddonType = "attach" | "fit" | "unicode11" | "web-links" | "webgl" | "ligatures";
1111

1212
export interface IXtermWindow extends Window {
13-
term: Terminal;
13+
terminal: Terminal | undefined;
1414
socket: ReconnectingWebSocket;
1515
handledMessages: string[];
1616
}

0 commit comments

Comments
 (0)