提交 e2341917 编写于 作者: D Daniel Imms

Fix undefined errors with xterm elements

Fixes #82622
上级 2290bae5
......@@ -30,7 +30,7 @@ export class NavigationModeAddon implements INavigationMode, ITerminalAddon {
}
focusPreviousLine(): void {
if (!this._terminal) {
if (!this._terminal || !this._terminal.element) {
return;
}
......@@ -73,7 +73,7 @@ export class NavigationModeAddon implements INavigationMode, ITerminalAddon {
}
focusNextLine(): void {
if (!this._terminal) {
if (!this._terminal || !this._terminal.element) {
return;
}
......
......@@ -565,6 +565,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._container.appendChild(this._wrapperElement);
xterm.open(this._xtermElement);
if (!xterm.element || !xterm.textarea) {
throw new Error('xterm elements not set after open');
}
xterm.textarea.addEventListener('focus', () => this._onFocus.fire(this));
xterm.attachCustomKeyEventHandler((event: KeyboardEvent): boolean => {
// Disable all input if the terminal is exiting
......@@ -1106,7 +1110,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
private _attachPressAnyKeyToCloseListener(xterm: XTermTerminal) {
if (!this._pressAnyKeyToCloseListener) {
if (xterm.textarea && !this._pressAnyKeyToCloseListener) {
this._pressAnyKeyToCloseListener = dom.addDisposableListener(xterm.textarea, 'keypress', (event: KeyboardEvent) => {
if (this._pressAnyKeyToCloseListener) {
this._pressAnyKeyToCloseListener.dispose();
......@@ -1309,7 +1313,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
return;
}
if (this._xterm) {
if (this._xterm && this._xterm.element) {
this._xterm.element.style.width = terminalWidth + 'px';
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册