@@ -3,7 +3,7 @@ import path = require("path");
33import * as url from "url" ;
44import { execSync } from "child_process" ;
55import * as vscode from "vscode" ;
6- import { config , schemas , workspaceState } from "../extension" ;
6+ import { config , schemas , workspaceState , terminals } from "../extension" ;
77
88export const outputChannel = vscode . window . createOutputChannel ( "ObjectScript" ) ;
99
@@ -137,7 +137,7 @@ export function notNull(el: any): boolean {
137137}
138138
139139export function portFromDockerCompose ( ) : { port : number ; docker : boolean } {
140- const { "docker-compose" : dockerCompose , port : defaultPort } = config ( "conn" ) ;
140+ const { "docker-compose" : dockerCompose = { } , port : defaultPort } = config ( "conn" ) ;
141141 const result = { port : defaultPort , docker : false } ;
142142 const { service, file = "docker-compose.yml" , internalPort = 52773 } = dockerCompose ;
143143 if ( ! internalPort || ! file || ! service || service === "" ) {
@@ -183,16 +183,20 @@ export async function terminalWithDocker(): Promise<vscode.Terminal> {
183183 const workspace = currentWorkspaceFolder ( ) ;
184184
185185 const terminalName = `ObjectScript:${ workspace } ` ;
186- const terminal = vscode . window . createTerminal ( terminalName , "docker-compose" , [
187- "-f" ,
188- file ,
189- "exec" ,
190- service ,
191- "/bin/bash" ,
192- "-c" ,
193- `[ -f /tmp/vscodesession.pid ] && kill $(cat /tmp/vscodesession.pid) >/dev/null 2>&1 ; echo $$ > /tmp/vscodesession.pid;
194- $(command -v ccontrol || command -v iris) session $ISC_PACKAGE_INSTANCENAME -U ${ ns } ` ,
195- ] ) ;
186+ let terminal = terminals . find ( ( t ) => t . name == terminalName && t . exitStatus == undefined ) ;
187+ if ( ! terminal ) {
188+ terminal = vscode . window . createTerminal ( terminalName , "docker-compose" , [
189+ "-f" ,
190+ file ,
191+ "exec" ,
192+ service ,
193+ "/bin/bash" ,
194+ "-c" ,
195+ `[ -f /tmp/vscodesession.pid ] && kill $(cat /tmp/vscodesession.pid) >/dev/null 2>&1 ; echo $$ > /tmp/vscodesession.pid;
196+ $(command -v ccontrol || command -v iris) session $ISC_PACKAGE_INSTANCENAME -U ${ ns } ` ,
197+ ] ) ;
198+ terminals . push ( terminal ) ;
199+ }
196200 terminal . show ( true ) ;
197201 return terminal ;
198202}
0 commit comments