mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-14 07:54:36 +01:00
@@ -20,6 +20,7 @@ import { attachSelectBoxStyler, attachStylerCallback } from 'vs/platform/theme/c
|
||||
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
|
||||
import { selectBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
const $ = dom.$;
|
||||
|
||||
@@ -42,6 +43,7 @@ export class StartDebugActionItem implements IActionItem {
|
||||
@IThemeService private themeService: IThemeService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@ICommandService private commandService: ICommandService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IContextViewService contextViewService: IContextViewService,
|
||||
) {
|
||||
this.toDispose = [];
|
||||
@@ -153,12 +155,13 @@ export class StartDebugActionItem implements IActionItem {
|
||||
this.options = [];
|
||||
const manager = this.debugService.getConfigurationManager();
|
||||
const launches = manager.getLaunches();
|
||||
const inWorkspace = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
|
||||
manager.getLaunches().forEach(launch =>
|
||||
launch.getConfigurationNames().forEach(name => {
|
||||
if (name === manager.selectedName && launch === manager.selectedLaunch) {
|
||||
this.selected = this.options.length;
|
||||
}
|
||||
const label = launches.length > 1 ? `${name} (${launch.name})` : name;
|
||||
const label = inWorkspace ? `${name} (${launch.name})` : name;
|
||||
this.options.push({ label, handler: () => { manager.selectConfiguration(launch, name); return true; } });
|
||||
}));
|
||||
|
||||
@@ -168,8 +171,8 @@ export class StartDebugActionItem implements IActionItem {
|
||||
this.options.push({ label: StartDebugActionItem.SEPARATOR, handler: undefined });
|
||||
|
||||
const disabledIdx = this.options.length - 1;
|
||||
launches.forEach(l => {
|
||||
const label = launches.length > 1 ? nls.localize("addConfigTo", "Add Config ({0})...", l.name) : nls.localize('addConfiguration', "Add Configuration...");
|
||||
launches.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: () => {
|
||||
this.commandService.executeCommand('debug.addConfiguration', l.uri.toString()).done(undefined, errors.onUnexpectedError);
|
||||
|
||||
@@ -109,8 +109,9 @@ export class DebugQuickOpenHandler extends Quickopen.QuickOpenHandler {
|
||||
configurations.push(new StartDebugEntry(this.debugService, this.contextService, this.messageService, launch, config, highlights));
|
||||
});
|
||||
}
|
||||
launches.forEach((l, index) => {
|
||||
const label = launches.length > 1 ? nls.localize("addConfigTo", "Add Config ({0})...", l.name) : nls.localize('addConfiguration', "Add Configuration...");
|
||||
launches.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, Filters.matchesContiguousSubString(input, label));
|
||||
if (index === 0) {
|
||||
configurations.push(new QuickOpenEntryGroup(entry, undefined, true));
|
||||
|
||||
@@ -448,6 +448,11 @@ export interface ILaunch {
|
||||
|
||||
workspace: IWorkspaceFolder;
|
||||
|
||||
/**
|
||||
* Should this launch be shown in the debug dropdown.
|
||||
*/
|
||||
hidden: boolean;
|
||||
|
||||
/**
|
||||
* Returns a configuration with the specified name.
|
||||
* Returns null if there is no configuration with the specified name.
|
||||
|
||||
@@ -34,6 +34,7 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
|
||||
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
|
||||
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { launchSchemaId } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences';
|
||||
|
||||
// debuggers extension point
|
||||
export const debuggersExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<IRawAdapter[]>('debuggers', [], {
|
||||
@@ -362,6 +363,7 @@ export class ConfigurationManager implements IConfigurationManager {
|
||||
|
||||
private initLaunches(): void {
|
||||
this.launches = this.contextService.getWorkspace().folders.map(folder => this.instantiationService.createInstance(Launch, this, folder));
|
||||
this.launches.push(this.instantiationService.createInstance(UserLaunch, this));
|
||||
if (this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE) {
|
||||
this.launches.push(this.instantiationService.createInstance(WorkspaceLaunch, this));
|
||||
}
|
||||
@@ -520,8 +522,12 @@ class Launch implements ILaunch {
|
||||
return this.workspace.name;
|
||||
}
|
||||
|
||||
public get hidden(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected getConfig(): IGlobalConfig {
|
||||
return this.configurationService.getValue<IGlobalConfig>('launch', { resource: this.workspace.uri });
|
||||
return this.configurationService.inspect<IGlobalConfig>('launch', { resource: this.workspace.uri }).workspaceFolder;
|
||||
}
|
||||
|
||||
public getCompound(name: string): ICompound {
|
||||
@@ -539,7 +545,7 @@ class Launch implements ILaunch {
|
||||
return [];
|
||||
} else {
|
||||
const names = config.configurations.filter(cfg => cfg && typeof cfg.name === 'string').map(cfg => cfg.name);
|
||||
if (includeCompounds && names.length > 0 && config.compounds) {
|
||||
if (includeCompounds && config.compounds) {
|
||||
if (config.compounds) {
|
||||
names.push(...config.compounds.filter(compound => typeof compound.name === 'string' && compound.configurations && compound.configurations.length)
|
||||
.map(compound => compound.name));
|
||||
@@ -668,3 +674,37 @@ class WorkspaceLaunch extends Launch implements ILaunch {
|
||||
return this.editorService.openEditor({ resource: this.workspaceContextService.getWorkspace().configuration });
|
||||
}
|
||||
}
|
||||
|
||||
class UserLaunch extends Launch implements ILaunch {
|
||||
|
||||
constructor(
|
||||
configurationManager: ConfigurationManager,
|
||||
@IFileService fileService: IFileService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IConfigurationResolverService configurationResolverService: IConfigurationResolverService,
|
||||
@IPreferencesService private preferencesService: IPreferencesService
|
||||
) {
|
||||
super(configurationManager, undefined, fileService, editorService, configurationService, configurationResolverService);
|
||||
}
|
||||
|
||||
get uri(): uri {
|
||||
return this.preferencesService.userSettingsResource;
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
return nls.localize('user settings', "user settings");
|
||||
}
|
||||
|
||||
public get hidden(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected getConfig(): IGlobalConfig {
|
||||
return this.configurationService.inspect<IGlobalConfig>('launch').user;
|
||||
}
|
||||
|
||||
openConfigFile(sideBySide: boolean, type?: string): TPromise<IEditor> {
|
||||
return this.preferencesService.openGlobalSettings();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user