Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support early customRequest #57716

Merged
merged 1 commit into from
Sep 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/vs/workbench/api/electron-browser/mainThreadDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -38,15 +39,20 @@ 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) {
this._proxy.$acceptDebugSessionCustomEvent(event.sessionId, session.configuration.type, session.configuration.name, event);
}
}));
}));
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));
Expand Down Expand Up @@ -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 {
Expand Down