@@ -20,8 +20,6 @@ import {
2020 TerminalShellType ,
2121} from './types' ;
2222import { traceVerbose } from '../../logging' ;
23- import { useEnvExtension } from '../../envExt/api.internal' ;
24- import { ensureTerminalLegacy } from '../../envExt/api.legacy' ;
2523import { sleep } from '../utils/async' ;
2624
2725@injectable ( )
@@ -81,6 +79,7 @@ export class TerminalService implements ITerminalService, Disposable {
8179 commandLine : string ,
8280 isPythonShell : boolean ,
8381 ) : Promise < TerminalShellExecution | undefined > {
82+ await this . ensureTerminal ( ) ;
8483 const terminal = this . terminal ! ;
8584 if ( ! this . options ?. hideFromUser ) {
8685 terminal . show ( true ) ;
@@ -128,33 +127,30 @@ export class TerminalService implements ITerminalService, Disposable {
128127 }
129128 }
130129 // TODO: Debt switch to Promise<Terminal> ---> breaks 20 tests
130+ // TODO: Properly migrate all creation, ensureTerminal to environment extension.
131131 public async ensureTerminal ( preserveFocus : boolean = true ) : Promise < void > {
132132 if ( this . terminal ) {
133133 return ;
134134 }
135135
136- if ( useEnvExtension ( ) ) {
137- this . terminal = await ensureTerminalLegacy ( this . options ?. resource , {
138- name : this . options ?. title || 'Python' ,
139- hideFromUser : this . options ?. hideFromUser ,
140- } ) ;
141- } else {
142- this . terminalShellType = this . terminalHelper . identifyTerminalShell ( this . terminal ) ;
143- this . terminal = this . terminalManager . createTerminal ( {
144- name : this . options ?. title || 'Python' ,
145- hideFromUser : this . options ?. hideFromUser ,
146- } ) ;
147- this . terminalAutoActivator . disableAutoActivation ( this . terminal ) ;
136+ // Always use the legacy terminal creation method for now
137+ // The environment extension path can create duplicate terminals
138+ // or show `Cannot read properties of undefined (reading 'show')` error: https://github.com/microsoft/vscode-python-environments/issues/958
139+ this . terminal = this . terminalManager . createTerminal ( {
140+ name : this . options ?. title || 'Python' ,
141+ hideFromUser : this . options ?. hideFromUser ,
142+ } ) ;
143+ this . terminalShellType = this . terminalHelper . identifyTerminalShell ( this . terminal ) ;
144+ this . terminalAutoActivator . disableAutoActivation ( this . terminal ) ;
148145
149- await sleep ( 100 ) ;
146+ await sleep ( 100 ) ;
150147
151- await this . terminalActivator . activateEnvironmentInTerminal ( this . terminal , {
152- resource : this . options ?. resource ,
153- preserveFocus,
154- interpreter : this . options ?. interpreter ,
155- hideFromUser : this . options ?. hideFromUser ,
156- } ) ;
157- }
148+ await this . terminalActivator . activateEnvironmentInTerminal ( this . terminal , {
149+ resource : this . options ?. resource ,
150+ preserveFocus,
151+ interpreter : this . options ?. interpreter ,
152+ hideFromUser : this . options ?. hideFromUser ,
153+ } ) ;
158154
159155 if ( ! this . options ?. hideFromUser ) {
160156 this . terminal . show ( preserveFocus ) ;
0 commit comments