@@ -11,14 +11,14 @@ import { ITerminalHelper, ITerminalService, TerminalShellType } from './types';
1111@injectable ( )
1212export class TerminalService implements ITerminalService , Disposable {
1313 private terminal ?: Terminal ;
14- private terminalShellType : TerminalShellType ;
14+ private terminalShellType ! : TerminalShellType ;
1515 private terminalClosed = new EventEmitter < void > ( ) ;
1616 private terminalManager : ITerminalManager ;
1717 private terminalHelper : ITerminalHelper ;
1818 public get onDidCloseTerminal ( ) : Event < void > {
1919 return this . terminalClosed . event ;
2020 }
21- constructor ( @inject ( IServiceContainer ) private serviceContainer : IServiceContainer ,
21+ constructor ( @inject ( IServiceContainer ) private serviceContainer : IServiceContainer ,
2222 private resource ?: Uri ,
2323 private title : string = 'Python' ) {
2424
@@ -44,11 +44,11 @@ export class TerminalService implements ITerminalService, Disposable {
4444 this . terminal ! . show ( true ) ;
4545 this . terminal ! . sendText ( text ) ;
4646 }
47- public async show ( ) : Promise < void > {
48- await this . ensureTerminal ( ) ;
49- this . terminal ! . show ( true ) ;
47+ public async show ( preserveFocus : boolean = true ) : Promise < void > {
48+ await this . ensureTerminal ( preserveFocus ) ;
49+ this . terminal ! . show ( preserveFocus ) ;
5050 }
51- private async ensureTerminal ( ) : Promise < void > {
51+ private async ensureTerminal ( preserveFocus : boolean = true ) : Promise < void > {
5252 if ( this . terminal ) {
5353 return ;
5454 }
@@ -62,7 +62,7 @@ export class TerminalService implements ITerminalService, Disposable {
6262 const activationCommamnds = await this . terminalHelper . getEnvironmentActivationCommands ( this . terminalShellType , this . resource ) ;
6363 if ( activationCommamnds ) {
6464 for ( const command of activationCommamnds ! ) {
65- this . terminal ! . show ( true ) ;
65+ this . terminal ! . show ( preserveFocus ) ;
6666 this . terminal ! . sendText ( command ) ;
6767
6868 // Give the command some time to complete.
@@ -71,7 +71,7 @@ export class TerminalService implements ITerminalService, Disposable {
7171 }
7272 }
7373
74- this . terminal ! . show ( true ) ;
74+ this . terminal ! . show ( preserveFocus ) ;
7575 }
7676 private terminalCloseHandler ( terminal : Terminal ) {
7777 if ( terminal === this . terminal ) {
0 commit comments