Skip to content

Commit 8e5ecd3

Browse files
committed
Dont execute command when terminal is not ready
1 parent 215c168 commit 8e5ecd3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/client/common/terminal/service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,14 @@ export class TerminalService implements ITerminalService, Disposable {
8181
commandLine: string,
8282
isPythonShell: boolean,
8383
): Promise<TerminalShellExecution | undefined> {
84-
const terminal = this.terminal!;
84+
// TODO: First execution of shift+enter may get ignored when using sendText.
85+
// Prevent Cannot read properties of undefined: https://github.com/microsoft/vscode-python-environments/issues/958
86+
if (!this.terminal) {
87+
traceVerbose('Terminal not available yet, cannot execute command');
88+
return undefined;
89+
}
90+
91+
const terminal = this.terminal;
8592
if (!this.options?.hideFromUser) {
8693
terminal.show(true);
8794
}
@@ -138,6 +145,7 @@ export class TerminalService implements ITerminalService, Disposable {
138145
name: this.options?.title || 'Python',
139146
hideFromUser: this.options?.hideFromUser,
140147
});
148+
return;
141149
} else {
142150
this.terminalShellType = this.terminalHelper.identifyTerminalShell(this.terminal);
143151
this.terminal = this.terminalManager.createTerminal({

0 commit comments

Comments
 (0)