diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 64a34f199f48f54fd405101e19efaa60f5fc1ed4..13ff283d5cf31fc38b112b7924b99b9c5cc46857 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -102,6 +102,7 @@ export interface ISession { export interface IProcess extends ITreeElement { name: string; + configuration: IConfig; session: ISession; getThread(threadId: number): IThread; getAllThreads(): IThread[]; diff --git a/src/vs/workbench/parts/debug/common/debugModel.ts b/src/vs/workbench/parts/debug/common/debugModel.ts index b3e4742ee31b8e08addb48c63122d289632305c0..9a1a4fba6387301c6b1bf40a5359d032ad628df9 100644 --- a/src/vs/workbench/parts/debug/common/debugModel.ts +++ b/src/vs/workbench/parts/debug/common/debugModel.ts @@ -492,7 +492,7 @@ export class Process implements debug.IProcess { private threads: Map; - constructor(public name: string, private _session: debug.ISession & debug.ITreeElement) { + constructor(public configuration: debug.IConfig, private _session: debug.ISession & debug.ITreeElement) { this.threads = new Map(); } @@ -500,6 +500,10 @@ export class Process implements debug.IProcess { return this._session; } + public get name(): string { + return this.configuration.name; + } + public getThread(threadId: number): Thread { return this.threads.get(threadId); } @@ -693,8 +697,8 @@ export class Model implements debug.IModel { return this.processes; } - public addProcess(name: string, session: debug.ISession & debug.ITreeElement): Process { - const process = new Process(name, session); + public addProcess(configuration: debug.IConfig, session: debug.ISession & debug.ITreeElement): Process { + const process = new Process(configuration, session); this.processes.push(process); return process; diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 90372cf582817fcd437eebaf5ddc0c62f37afd6e..6ef7357309c1a58531097aa8aa4d7fcae12dc131 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -665,7 +665,7 @@ export class DebugService implements debug.IDebugService { } const session = this.instantiationService.createInstance(RawDebugSession, sessionId, configuration.debugServer, adapter, this.customTelemetryService); - const process = this.model.addProcess(configuration.name, session); + const process = this.model.addProcess(configuration, session); if (!this.viewModel.focusedProcess) { this.focusStackFrameAndEvaluate(null, process); @@ -825,13 +825,13 @@ export class DebugService implements debug.IDebugService { return process.session.disconnect(true).then(() => new TPromise((c, e) => { setTimeout(() => { - this.createProcess(process.name).then(() => c(null), err => e(err)); + this.createProcess(process.configuration).then(() => c(null), err => e(err)); }, 300); }) ).then(() => { if (preserveFocus) { // Restart should preserve the focused process - const restartedProcess = this.model.getProcesses().filter(p => p.name === process.name).pop(); + const restartedProcess = this.model.getProcesses().filter(p => p.getId() === process.getId()).pop(); if (restartedProcess && restartedProcess !== this.viewModel.focusedProcess) { this.focusStackFrameAndEvaluate(null, restartedProcess); } diff --git a/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts b/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts index ba5817979bfe6f3e338ddd68b8e02d2394f6dfdb..31dd5f1f8d8f20157e415f3a6996658babac9b0e 100644 --- a/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts +++ b/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts @@ -23,7 +23,7 @@ suite('Debug - View Model', () => { assert.equal(model.focusedStackFrame, null); assert.equal(model.focusedThread, null); const mockSession = new MockSession(); - const process = new Process('mockProcess', mockSession); + const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, mockSession); const thread = new Thread(process, 'myThread', 1); const frame = new StackFrame(thread, 1, null, 'app.js', 1, 1); model.setFocusedStackFrame(frame, process); diff --git a/src/vs/workbench/parts/debug/test/node/debugModel.test.ts b/src/vs/workbench/parts/debug/test/node/debugModel.test.ts index 59842d14a8464b0f569960f417b9ea66b91c7ffe..c99bdfe29cc8e6e7f78d63433e5f55d9b35e73c3 100644 --- a/src/vs/workbench/parts/debug/test/node/debugModel.test.ts +++ b/src/vs/workbench/parts/debug/test/node/debugModel.test.ts @@ -94,7 +94,7 @@ suite('Debug - Model', () => { const threadId = 1; const threadName = 'firstThread'; - model.addProcess('mockProcess', rawSession); + model.addProcess({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); assert.equal(model.getProcesses().length, 1); model.rawUpdate({ sessionId: rawSession.getId(), @@ -125,7 +125,7 @@ suite('Debug - Model', () => { const stoppedReason = 'breakpoint'; // Add the threads - model.addProcess('mockProcess', rawSession); + model.addProcess({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); model.rawUpdate({ sessionId: rawSession.getId(), threadId: threadId1, @@ -215,7 +215,7 @@ suite('Debug - Model', () => { const runningThreadId = 2; const runningThreadName = 'runningThread'; const stoppedReason = 'breakpoint'; - model.addProcess('mockProcess', rawSession); + model.addProcess({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); // Add the threads model.rawUpdate({ sessionId: rawSession.getId(), @@ -308,7 +308,7 @@ suite('Debug - Model', () => { test('watch expressions', () => { assert.equal(model.getWatchExpressions().length, 0); - const process = new Process('mockProcess', rawSession); + const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); const thread = new Thread(process, 'mockthread', 1); const stackFrame = new StackFrame(thread, 1, null, 'app.js', 1, 1); model.addWatchExpression(process, stackFrame, 'console').done(); @@ -336,7 +336,7 @@ suite('Debug - Model', () => { test('repl expressions', () => { assert.equal(model.getReplElements().length, 0); - const process = new Process('mockProcess', rawSession); + const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession); const thread = new Thread(process, 'mockthread', 1); const stackFrame = new StackFrame(thread, 1, null, 'app.js', 1, 1); model.addReplExpression(process, stackFrame, 'myVariable').done();