Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/client/common/terminal/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import {
TerminalShellType,
} from './types';
import { traceVerbose } from '../../logging';
import { sleep } from '../utils/async';
import { useEnvExtension } from '../../envExt/api.internal';
import { ensureTerminalLegacy } from '../../envExt/api.legacy';
import { sleep } from '../utils/async';

@injectable()
export class TerminalService implements ITerminalService, Disposable {
Expand Down Expand Up @@ -81,7 +81,14 @@ export class TerminalService implements ITerminalService, Disposable {
commandLine: string,
isPythonShell: boolean,
): Promise<TerminalShellExecution | undefined> {
const terminal = this.terminal!;
// TODO: First execution of shift+enter may get ignored when using sendText.
// Prevent Cannot read properties of undefined: https://github.com/microsoft/vscode-python-environments/issues/958
if (!this.terminal) {
traceVerbose('Terminal not available yet, cannot execute command');
return undefined;
}

const terminal = this.terminal;
if (!this.options?.hideFromUser) {
terminal.show(true);
}
Expand Down Expand Up @@ -128,6 +135,7 @@ export class TerminalService implements ITerminalService, Disposable {
}
}
// TODO: Debt switch to Promise<Terminal> ---> breaks 20 tests
// TODO: Properly migrate all creation, ensureTerminal to environment extension.
public async ensureTerminal(preserveFocus: boolean = true): Promise<void> {
if (this.terminal) {
return;
Expand All @@ -138,6 +146,7 @@ export class TerminalService implements ITerminalService, Disposable {
name: this.options?.title || 'Python',
hideFromUser: this.options?.hideFromUser,
});
return;
} else {
this.terminalShellType = this.terminalHelper.identifyTerminalShell(this.terminal);
this.terminal = this.terminalManager.createTerminal({
Expand Down
Loading