From 41afff235b60b82afcfe271e1663f15f0ec5e121 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Mon, 29 Jan 2018 10:46:37 -0800 Subject: [PATCH] Restore automatically putting TS Server in debug more if TSS_DEBUG is set Fixes https://github.com/Microsoft/TypeScript/issues/21454 --- .../typescript/src/typescriptServiceClient.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/extensions/typescript/src/typescriptServiceClient.ts b/extensions/typescript/src/typescriptServiceClient.ts index a36818b3905..595d56d117f 100644 --- a/extensions/typescript/src/typescriptServiceClient.ts +++ b/extensions/typescript/src/typescriptServiceClient.ts @@ -354,8 +354,9 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient return this.servicePromise = new Promise(async (resolve, reject) => { try { const tsServerForkArgs = await this.getTsServerArgs(currentVersion); + const debugPort = this.getDebugPort(); const tsServerForkOptions: electron.IForkOptions = { - execArgv: [] // [`--debug-brk=5859`] + execArgv: debugPort ? [`--inspect=${debugPort}`] : [] // [`--debug-brk=5859`] }; electron.fork(currentVersion.tsServerPath, tsServerForkArgs, tsServerForkOptions, this.logger, (err: any, childProcess: cp.ChildProcess | null) => { if (err || !childProcess) { @@ -942,6 +943,18 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient return args; } + + private getDebugPort(): number | undefined { + const value = process.env['TSS_DEBUG']; + if (value) { + const port = parseInt(value); + if (!isNaN(port)) { + return port; + } + } + return undefined; + } + private resetClientVersion() { this._apiVersion = API.defaultVersion; this._tsserverVersion = undefined;