@@ -3,7 +3,7 @@ import path = require("path");
3
3
import * as url from "url" ;
4
4
import { execSync } from "child_process" ;
5
5
import * as vscode from "vscode" ;
6
- import { config , schemas , workspaceState } from "../extension" ;
6
+ import { config , schemas , workspaceState , terminals } from "../extension" ;
7
7
8
8
export const outputChannel = vscode . window . createOutputChannel ( "ObjectScript" ) ;
9
9
@@ -137,7 +137,7 @@ export function notNull(el: any): boolean {
137
137
}
138
138
139
139
export function portFromDockerCompose ( ) : { port : number ; docker : boolean } {
140
- const { "docker-compose" : dockerCompose , port : defaultPort } = config ( "conn" ) ;
140
+ const { "docker-compose" : dockerCompose = { } , port : defaultPort } = config ( "conn" ) ;
141
141
const result = { port : defaultPort , docker : false } ;
142
142
const { service, file = "docker-compose.yml" , internalPort = 52773 } = dockerCompose ;
143
143
if ( ! internalPort || ! file || ! service || service === "" ) {
@@ -183,16 +183,20 @@ export async function terminalWithDocker(): Promise<vscode.Terminal> {
183
183
const workspace = currentWorkspaceFolder ( ) ;
184
184
185
185
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
+ }
196
200
terminal . show ( true ) ;
197
201
return terminal ;
198
202
}
0 commit comments