未验证 提交 84fe6dc3 编写于 作者: C Connor Peet 提交者: GitHub

fix: add an option to stopAll in compound launch configs (#98206)

* fix: add an option to stopAll in compound launch configs

* fixup! pr comments
上级 af6649b9
......@@ -46,6 +46,7 @@ import { IViewsService } from 'vs/workbench/common/views';
import { generateUuid } from 'vs/base/common/uuid';
import { DebugStorage } from 'vs/workbench/contrib/debug/common/debugStorage';
import { DebugTelemetry } from 'vs/workbench/contrib/debug/common/debugTelemetry';
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
export class DebugService implements IDebugService {
_serviceBrand: undefined;
......@@ -305,6 +306,9 @@ export class DebugService implements IDebugService {
return false;
}
}
if (compound.stopAll) {
options = { ...options, compoundRoot: new DebugCompoundRoot() };
}
const values = await Promise.all(compound.configurations.map(configData => {
const name = typeof configData === 'string' ? configData : configData.name;
......
......@@ -98,6 +98,11 @@ export class DebugSession implements IDebugSession {
dispose(toDispose);
}));
}
const compoundRoot = this._options.compoundRoot;
if (compoundRoot) {
toDispose.push(compoundRoot.onDidSessionStop(() => this.terminate()));
}
}
getId(): string {
......@@ -280,6 +285,10 @@ export class DebugSession implements IDebugSession {
} else {
await this.raw.disconnect(restart);
}
if (!restart) {
this._options.compoundRoot?.sessionStopped();
}
}
/**
......@@ -292,6 +301,10 @@ export class DebugSession implements IDebugSession {
this.cancelAllRequests();
await this.raw.disconnect(restart);
if (!restart) {
this._options.compoundRoot?.sessionStopped();
}
}
/**
......
......@@ -24,6 +24,7 @@ import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService'
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { CancellationToken } from 'vs/base/common/cancellation';
import { DebugConfigurationProviderTriggerKind } from 'vs/workbench/api/common/extHostTypes';
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
export const VIEWLET_ID = 'workbench.view.debug';
......@@ -155,6 +156,7 @@ export interface IDebugSessionOptions {
noDebug?: boolean;
parentSession?: IDebugSession;
repl?: IDebugSessionReplMode;
compoundRoot?: DebugCompoundRoot;
}
export interface IDebugSession extends ITreeElement {
......@@ -518,6 +520,7 @@ export interface IConfig extends IEnvConfig {
export interface ICompound {
name: string;
stopAll?: boolean;
preLaunchTask?: string | TaskIdentifier;
configurations: (string | { name: string, folder: string })[];
presentation?: IConfigPresentation;
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Emitter } from 'vs/base/common/event';
export class DebugCompoundRoot {
private stopped = false;
private stopEmitter = new Emitter<void>();
onDidSessionStop = this.stopEmitter.event;
sessionStopped(): void {
if (!this.stopped) { // avoid sending extranous terminate events
this.stopped = true;
this.stopEmitter.fire();
}
}
}
......@@ -215,6 +215,11 @@ export const launchSchema: IJSONSchema = {
},
description: nls.localize('app.launch.json.compounds.configurations', "Names of configurations that will be started as part of this compound.")
},
stopAll: {
type: 'boolean',
default: false,
description: nls.localize('app.launch.json.compound.stopAll', "Controls whether manually terminating one session will stop all of the compound sessions.")
},
preLaunchTask: {
type: 'string',
default: '',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册