提交 812fe77b 编写于 作者: A Andre Weinand

support early customRequest

上级 86d305f5
......@@ -6,7 +6,7 @@
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import uri from 'vs/base/common/uri';
import { IDebugService, IConfig, IDebugConfigurationProvider, IBreakpoint, IFunctionBreakpoint, IBreakpointData, IAdapterExecutable, ITerminalSettings, IDebugAdapter, IDebugAdapterProvider } from 'vs/workbench/parts/debug/common/debug';
import { IDebugService, IConfig, IDebugConfigurationProvider, IBreakpoint, IFunctionBreakpoint, IBreakpointData, IAdapterExecutable, ITerminalSettings, IDebugAdapter, IDebugAdapterProvider, ISession } from 'vs/workbench/parts/debug/common/debug';
import { TPromise } from 'vs/base/common/winjs.base';
import {
ExtHostContext, ExtHostDebugServiceShape, MainThreadDebugServiceShape, DebugSessionUUID, MainContext,
......@@ -28,6 +28,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
private _breakpointEventsActive: boolean;
private _debugAdapters: Map<number, ExtensionHostDebugAdapter>;
private _debugAdaptersHandleCounter = 1;
private _sessions: Map<DebugSessionUUID, ISession>;
constructor(
extHostContext: IExtHostContext,
......@@ -38,7 +39,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
this._toDispose.push(debugService.onDidNewSession(session => {
this._proxy.$acceptDebugSessionStarted(<DebugSessionUUID>session.getId(), session.configuration.type, session.getName(false));
}));
this._sessions = new Map();
this._toDispose.push(debugService.onWillNewSession(session => {
this._sessions.set(session.getId(), session);
// Need to start listening early to new session events because a custom event can come while a session is initialising
this._toDispose.push(session.onDidCustomEvent(event => {
if (event && event.sessionId) {
......@@ -46,7 +49,10 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
}
}));
}));
this._toDispose.push(debugService.onDidEndSession(proc => this._proxy.$acceptDebugSessionTerminated(<DebugSessionUUID>proc.getId(), proc.configuration.type, proc.getName(false))));
this._toDispose.push(debugService.onDidEndSession(session => {
this._proxy.$acceptDebugSessionTerminated(<DebugSessionUUID>session.getId(), session.configuration.type, session.getName(false));
this._sessions.delete(<DebugSessionUUID>session.getId());
}));
this._toDispose.push(debugService.getViewModel().onDidFocusSession(proc => {
if (proc) {
this._proxy.$acceptDebugSessionActiveChanged(<DebugSessionUUID>proc.getId(), proc.configuration.type, proc.getName(false));
......@@ -220,9 +226,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
}
public $customDebugAdapterRequest(sessionId: DebugSessionUUID, request: string, args: any): TPromise<any> {
const process = this.debugService.getModel().getSessions().filter(p => p.getId() === sessionId).pop();
if (process) {
return process.raw.custom(request, args).then(response => {
const session = this._sessions.get(sessionId);
if (session) {
return session.raw.custom(request, args).then(response => {
if (response && response.success) {
return response.body;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册