提交 d27ed199 编写于 作者: I isidor

Debug: Support launch config grouping and sorting

fixes #82332
上级 e94ab839
......@@ -157,16 +157,14 @@ export class StartDebugActionViewItem implements IActionViewItem {
this.selected = 0;
this.options = [];
const manager = this.debugService.getConfigurationManager();
const launches = manager.getLaunches();
const inWorkspace = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
launches.forEach(launch =>
launch.getConfigurationNames().forEach(name => {
if (name === manager.selectedConfiguration.name && launch === manager.selectedConfiguration.launch) {
this.selected = this.options.length;
}
const label = inWorkspace ? `${name} (${launch.name})` : name;
this.options.push({ label, handler: () => { manager.selectConfiguration(launch, name); return true; } });
}));
manager.getAllConfigurations().forEach(({ launch, name }) => {
if (name === manager.selectedConfiguration.name && launch === manager.selectedConfiguration.launch) {
this.selected = this.options.length;
}
const label = inWorkspace ? `${name} (${launch.name})` : name;
this.options.push({ label, handler: () => { manager.selectConfiguration(launch, name); return true; } });
});
if (this.options.length === 0) {
this.options.push({ label: nls.localize('noConfigurations', "No Configurations"), handler: () => false });
......@@ -175,7 +173,7 @@ export class StartDebugActionViewItem implements IActionViewItem {
}
const disabledIdx = this.options.length - 1;
launches.filter(l => !l.hidden).forEach(l => {
manager.getLaunches().filter(l => !l.hidden).forEach(l => {
const label = inWorkspace ? nls.localize("addConfigTo", "Add Config ({0})...", l.name) : nls.localize('addConfiguration', "Add Configuration...");
this.options.push({
label, handler: () => {
......
......@@ -21,7 +21,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import { IWorkspaceContextService, IWorkspaceFolder, WorkbenchState, IWorkspaceFoldersChangeEvent } from 'vs/platform/workspace/common/workspace';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IDebugConfigurationProvider, ICompound, IDebugConfiguration, IConfig, IGlobalConfig, IConfigurationManager, ILaunch, IDebugAdapterDescriptorFactory, IDebugAdapter, IDebugSession, IAdapterDescriptor, CONTEXT_DEBUG_CONFIGURATION_TYPE, IDebugAdapterFactory } from 'vs/workbench/contrib/debug/common/debug';
import { IDebugConfigurationProvider, ICompound, IDebugConfiguration, IConfig, IGlobalConfig, IConfigurationManager, ILaunch, IDebugAdapterDescriptorFactory, IDebugAdapter, IDebugSession, IAdapterDescriptor, CONTEXT_DEBUG_CONFIGURATION_TYPE, IDebugAdapterFactory, IConfigPresentation } from 'vs/workbench/contrib/debug/common/debug';
import { Debugger } from 'vs/workbench/contrib/debug/common/debugger';
import { IEditorService, ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
......@@ -214,6 +214,43 @@ export class ConfigurationManager implements IConfigurationManager {
return results.reduce((first, second) => first.concat(second), []);
}
getAllConfigurations(): { launch: ILaunch; name: string; }[] {
const all: { launch: ILaunch, name: string, presentation?: IConfigPresentation }[] = [];
for (let l of this.launches) {
for (let name of l.getConfigurationNames()) {
const config = l.getConfiguration(name) || l.getCompound(name);
if (config && !config.presentation?.hidden) {
all.push({ launch: l, name, presentation: config.presentation });
}
}
}
return all.sort((first, second) => {
if (!first.presentation) {
return 1;
}
if (!second.presentation) {
return -1;
}
if (!first.presentation.group) {
return 1;
}
if (!second.presentation.group) {
return -1;
}
if (first.presentation.group !== second.presentation.group) {
return first.presentation.group.localeCompare(second.presentation.group);
}
if (typeof first.presentation.order !== 'number') {
return 1;
}
if (typeof second.presentation.order !== 'number') {
return -1;
}
return first.presentation.order - second.presentation.order;
});
}
private registerListeners(): void {
debuggersExtPoint.setHandler((extensions, delta) => {
delta.added.forEach(added => {
......
......@@ -96,18 +96,18 @@ export class DebugQuickOpenHandler extends QuickOpenHandler {
const configurations: QuickOpenEntry[] = [];
const configManager = this.debugService.getConfigurationManager();
const launches = configManager.getLaunches();
for (let launch of launches) {
launch.getConfigurationNames().map(config => ({ config: config, highlights: matchesFuzzy(input, config, true) || undefined }))
.filter(({ highlights }) => !!highlights)
.forEach(({ config, highlights }) => {
if (launch === configManager.selectedConfiguration.launch && config === configManager.selectedConfiguration.name) {
this.autoFocusIndex = configurations.length;
}
configurations.push(new StartDebugEntry(this.debugService, this.contextService, this.notificationService, launch, config, highlights));
});
const allConfigurations = configManager.getAllConfigurations();
for (let config of allConfigurations) {
const highlights = matchesFuzzy(input, config.name, true);
if (highlights) {
if (config.launch === configManager.selectedConfiguration.launch && config.name === configManager.selectedConfiguration.name) {
this.autoFocusIndex = configurations.length;
}
configurations.push(new StartDebugEntry(this.debugService, this.contextService, this.notificationService, config.launch, config.name, highlights));
}
}
launches.filter(l => !l.hidden).forEach((l, index) => {
configManager.getLaunches().filter(l => !l.hidden).forEach((l, index) => {
const label = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE ? nls.localize("addConfigTo", "Add Config ({0})...", l.name) : nls.localize('addConfiguration', "Add Configuration...");
const entry = new AddConfigEntry(label, l, this.commandService, this.contextService, matchesFuzzy(input, label, true) || undefined);
......
......@@ -487,13 +487,19 @@ export interface IEnvConfig {
noDebug?: boolean;
}
export interface IConfigPresentation {
hidden?: boolean;
group?: string;
order?: number;
}
export interface IConfig extends IEnvConfig {
// fundamental attributes
type: string;
request: string;
name: string;
presentation?: IConfigPresentation;
// platform specifics
windows?: IEnvConfig;
osx?: IEnvConfig;
......@@ -510,6 +516,7 @@ export interface ICompound {
name: string;
preLaunchTask?: string | TaskIdentifier;
configurations: (string | { name: string, folder: string })[];
presentation?: IConfigPresentation;
}
export interface IDebugAdapter extends IDisposable {
......@@ -631,6 +638,8 @@ export interface IConfigurationManager {
getLaunch(workspaceUri: uri | undefined): ILaunch | undefined;
getAllConfigurations(): { launch: ILaunch, name: string }[];
/**
* Allows to register on change of selected debug configuration.
*/
......
......@@ -132,6 +132,33 @@ export const breakpointsExtPoint = extensionsRegistry.ExtensionsRegistry.registe
});
// debug general schema
export const presentationSchema: IJSONSchema = {
type: 'object',
description: nls.localize('presentation', "Presentation options on how to show this configuration in the debug configuration dropdown and the command palette."),
properties: {
hidden: {
type: 'boolean',
default: false,
description: nls.localize('presentation.hidden', "Controls if this configuration should be shown in the configuration dropdown and the command palette.")
},
group: {
type: 'string',
default: '',
description: nls.localize('presentation.group', "Group that this configuration belongs to. Used for grouping and sorting in the configuration dropdown and the command palette.")
},
order: {
type: 'number',
default: 1,
description: nls.localize('presentation.order', "Order of this configuration within a group. Used for grouping and sorting in the configuration dropdown and the command palette.")
}
},
default: {
hidden: false,
group: '',
order: 1
}
};
const defaultCompound: ICompound = { name: 'Compound', configurations: [] };
export const launchSchema: IJSONSchema = {
id: launchSchemaId,
......@@ -167,6 +194,7 @@ export const launchSchema: IJSONSchema = {
type: 'string',
description: nls.localize('app.launch.json.compound.name', "Name of compound. Appears in the launch configuration drop down menu.")
},
presentation: presentationSchema,
configurations: {
type: 'array',
default: [],
......
......@@ -22,6 +22,7 @@ import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
import { isDebuggerMainContribution } from 'vs/workbench/contrib/debug/common/debugUtils';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { presentationSchema } from 'vs/workbench/contrib/debug/common/debugSchemas';
export class Debugger implements IDebugger {
......@@ -222,7 +223,7 @@ export class Debugger implements IDebugger {
};
properties['name'] = {
type: 'string',
description: nls.localize('debugName', "Name of configuration; appears in the launch configuration drop down menu."),
description: nls.localize('debugName', "Name of configuration; appears in the launch configuration dropdown menu."),
default: 'Launch'
};
properties['request'] = {
......@@ -250,6 +251,7 @@ export class Debugger implements IDebugger {
defaultSnippets: [{ body: { task: '', type: '' } }],
description: nls.localize('debugPostDebugTask', "Task to run after debug session ends.")
};
properties['presentation'] = presentationSchema;
properties['internalConsoleOptions'] = INTERNAL_CONSOLE_OPTIONS_SCHEMA;
// Clear out windows, linux and osx fields to not have cycles inside the properties object
delete properties['windows'];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册