Merge VS Code 1.21 source code (#1067)

* Initial VS Code 1.21 file copy with patches

* A few more merges

* Post npm install

* Fix batch of build breaks

* Fix more build breaks

* Fix more build errors

* Fix more build breaks

* Runtime fixes 1

* Get connection dialog working with some todos

* Fix a few packaging issues

* Copy several node_modules to package build to fix loader issues

* Fix breaks from master

* A few more fixes

* Make tests pass

* First pass of license header updates

* Second pass of license header updates

* Fix restore dialog issues

* Remove add additional themes menu items

* fix select box issues where the list doesn't show up

* formatting

* Fix editor dispose issue

* Copy over node modules to correct location on all platforms
This commit is contained in:
Karl Burtram
2018-04-04 15:27:51 -07:00
committed by GitHub
parent 5fba3e31b4
commit dafb780987
9412 changed files with 141255 additions and 98813 deletions

View File

@@ -0,0 +1,36 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { TPromise } from 'vs/base/common/winjs.base';
import nls = require('vs/nls');
import { Action } from 'vs/base/common/actions';
import { Registry } from 'vs/platform/registry/common/platform';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
import { IPartService } from 'vs/workbench/services/part/common/partService';
class ToggleCenteredLayout extends Action {
public static readonly ID = 'workbench.action.toggleCenteredLayout';
public static readonly LABEL = nls.localize('toggleCenteredLayout', "Toggle Centered Layout");
constructor(
id: string,
label: string,
@IPartService private partService: IPartService
) {
super(id, label);
this.enabled = !!this.partService;
}
public run(): TPromise<any> {
this.partService.toggleCenteredEditorLayout();
return TPromise.as(null);
}
}
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleCenteredLayout, ToggleCenteredLayout.ID, ToggleCenteredLayout.LABEL), 'View: Toggle Centered Layout', nls.localize('view', "View"));

View File

@@ -81,4 +81,4 @@ CommandsRegistry.registerCommand('_workbench.editor.setGroupOrientation', functi
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
const group = nls.localize('view', "View");
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleEditorLayoutAction, ToggleEditorLayoutAction.ID, ToggleEditorLayoutAction.LABEL, { primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_1, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_1 } }), 'View: Toggle Editor Group Vertical/Horizontal Layout', group);
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleEditorLayoutAction, ToggleEditorLayoutAction.ID, ToggleEditorLayoutAction.LABEL, { primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_0, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_0 } }), 'View: Toggle Editor Group Vertical/Horizontal Layout', group);

View File

@@ -16,7 +16,7 @@ import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configur
export class ToggleSidebarPositionAction extends Action {
public static readonly ID = 'workbench.action.toggleSidebarPosition';
public static readonly LABEL = nls.localize('toggleLocation', "Toggle Side Bar Location");
public static readonly LABEL = nls.localize('toggleSidebarPosition', "Toggle Side Bar Position");
private static readonly sidebarPositionConfigurationKey = 'workbench.sideBar.location';
@@ -40,4 +40,4 @@ export class ToggleSidebarPositionAction extends Action {
}
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleSidebarPositionAction, ToggleSidebarPositionAction.ID, ToggleSidebarPositionAction.LABEL), 'View: Toggle Side Bar Location', nls.localize('view', "View"));
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleSidebarPositionAction, ToggleSidebarPositionAction.ID, ToggleSidebarPositionAction.LABEL), 'View: Toggle Side Bar Position', nls.localize('view', "View"));

View File

@@ -12,25 +12,17 @@ import { IWindowService, IWindowsService } from 'vs/platform/windows/common/wind
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import URI from 'vs/base/common/uri';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { WORKSPACE_FILTER, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { isLinux } from 'vs/base/common/platform';
import { dirname } from 'vs/base/common/paths';
import * as resources from 'vs/base/common/resources';
import { mnemonicButtonLabel, getPathLabel } from 'vs/base/common/labels';
import { isParent, FileKind } from 'vs/platform/files/common/files';
import { mnemonicButtonLabel } from 'vs/base/common/labels';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IQuickOpenService, IFilePickOpenEntry, IPickOptions } from 'vs/platform/quickOpen/common/quickOpen';
import { CancellationToken } from 'vs/base/common/cancellation';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL, PICK_WORKSPACE_FOLDER_COMMAND_ID, defaultWorkspacePath, defaultFilePath, defaultFolderPath } from 'vs/workbench/browser/actions/workspaceCommands';
export class OpenFileAction extends Action {
static ID = 'workbench.action.files.openFile';
static readonly ID = 'workbench.action.files.openFile';
static LABEL = nls.localize('openFile', "Open File...");
constructor(
@@ -50,7 +42,7 @@ export class OpenFileAction extends Action {
export class OpenFolderAction extends Action {
static ID = 'workbench.action.files.openFolder';
static readonly ID = 'workbench.action.files.openFolder';
static LABEL = nls.localize('openFolder', "Open Folder...");
constructor(
@@ -70,7 +62,7 @@ export class OpenFolderAction extends Action {
export class OpenFileFolderAction extends Action {
static ID = 'workbench.action.files.openFileFolder';
static readonly ID = 'workbench.action.files.openFileFolder';
static LABEL = nls.localize('openFileFolder', "Open...");
constructor(
@@ -88,156 +80,37 @@ export class OpenFileFolderAction extends Action {
}
}
export const openFileFolderInNewWindowCommand = (accessor: ServicesAccessor) => {
const { windowService, historyService, contextService } = services(accessor);
export class AddRootFolderAction extends Action {
windowService.pickFileFolderAndOpen({ forceNewWindow: true, dialogOptions: { defaultPath: defaultFilePath(contextService, historyService) } });
};
export const openFolderCommand = (accessor: ServicesAccessor, forceNewWindow: boolean) => {
const { windowService, historyService, contextService } = services(accessor);
windowService.pickFolderAndOpen({ forceNewWindow, dialogOptions: { defaultPath: defaultFolderPath(contextService, historyService) } });
};
export const openFolderInNewWindowCommand = (accessor: ServicesAccessor) => {
const { windowService, historyService, contextService } = services(accessor);
windowService.pickFolderAndOpen({ forceNewWindow: true, dialogOptions: { defaultPath: defaultFolderPath(contextService, historyService) } });
};
export const openFileInNewWindowCommand = (accessor: ServicesAccessor) => {
const { windowService, historyService, contextService } = services(accessor);
windowService.pickFileAndOpen({ forceNewWindow: true, dialogOptions: { defaultPath: defaultFilePath(contextService, historyService) } });
};
export const openWorkspaceInNewWindowCommand = (accessor: ServicesAccessor) => {
const { windowService, historyService, contextService, environmentService } = services(accessor);
windowService.pickWorkspaceAndOpen({ forceNewWindow: true, dialogOptions: { defaultPath: defaultWorkspacePath(contextService, historyService, environmentService) } });
};
function services(accessor: ServicesAccessor): { windowService: IWindowService, historyService: IHistoryService, contextService: IWorkspaceContextService, environmentService: IEnvironmentService } {
return {
windowService: accessor.get(IWindowService),
historyService: accessor.get(IHistoryService),
contextService: accessor.get(IWorkspaceContextService),
environmentService: accessor.get(IEnvironmentService)
};
}
export abstract class BaseWorkspacesAction extends Action {
static readonly ID = 'workbench.action.addRootFolder';
static LABEL = ADD_ROOT_FOLDER_LABEL;
constructor(
id: string,
label: string,
protected windowService: IWindowService,
protected environmentService: IEnvironmentService,
protected contextService: IWorkspaceContextService,
protected historyService: IHistoryService
@ICommandService private commandService: ICommandService
) {
super(id, label);
}
protected pickFolders(buttonLabel: string, title: string): string[] {
return this.windowService.showOpenDialog({
buttonLabel,
title,
properties: ['multiSelections', 'openDirectory', 'createDirectory'],
defaultPath: defaultFolderPath(this.contextService, this.historyService)
});
}
}
function defaultFilePath(contextService: IWorkspaceContextService, historyService: IHistoryService): string {
let candidate: URI;
// Check for last active file first...
candidate = historyService.getLastActiveFile();
// ...then for last active file root
if (!candidate) {
candidate = historyService.getLastActiveWorkspaceRoot('file');
}
return candidate ? dirname(candidate.fsPath) : void 0;
}
function defaultFolderPath(contextService: IWorkspaceContextService, historyService: IHistoryService): string {
let candidate: URI;
// Check for last active file root first...
candidate = historyService.getLastActiveWorkspaceRoot('file');
// ...then for last active file
if (!candidate) {
candidate = historyService.getLastActiveFile();
}
return candidate ? dirname(candidate.fsPath) : void 0;
}
function defaultWorkspacePath(contextService: IWorkspaceContextService, historyService: IHistoryService, environmentService: IEnvironmentService): string {
// Check for current workspace config file first...
if (contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && !isUntitledWorkspace(contextService.getWorkspace().configuration.fsPath, environmentService)) {
return dirname(contextService.getWorkspace().configuration.fsPath);
}
// ...then fallback to default folder path
return defaultFolderPath(contextService, historyService);
}
function isUntitledWorkspace(path: string, environmentService: IEnvironmentService): boolean {
return isParent(path, environmentService.workspacesHome, !isLinux /* ignore case */);
}
export class AddRootFolderAction extends BaseWorkspacesAction {
static ID = 'workbench.action.addRootFolder';
static LABEL = nls.localize('addFolderToWorkspace', "Add Folder to Workspace...");
constructor(
id: string,
label: string,
@IWindowService windowService: IWindowService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IEnvironmentService environmentService: IEnvironmentService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService,
@IViewletService private viewletService: IViewletService,
@IHistoryService historyService: IHistoryService
) {
super(id, label, windowService, environmentService, contextService, historyService);
}
public run(): TPromise<any> {
const folders = super.pickFolders(mnemonicButtonLabel(nls.localize({ key: 'add', comment: ['&& denotes a mnemonic'] }, "&&Add")), nls.localize('addFolderToWorkspaceTitle', "Add Folder to Workspace"));
if (!folders || !folders.length) {
return TPromise.as(null);
}
// Add and show Files Explorer viewlet
return this.workspaceEditingService.addFolders(folders.map(folder => ({ uri: URI.file(folder) }))).then(() => this.viewletService.openViewlet(this.viewletService.getDefaultViewletId(), true));
return this.commandService.executeCommand(ADD_ROOT_FOLDER_COMMAND_ID);
}
}
export class GlobalRemoveRootFolderAction extends BaseWorkspacesAction {
export class GlobalRemoveRootFolderAction extends Action {
static ID = 'workbench.action.removeRootFolder';
static readonly ID = 'workbench.action.removeRootFolder';
static LABEL = nls.localize('globalRemoveFolderFromWorkspace', "Remove Folder from Workspace...");
constructor(
id: string,
label: string,
@IWindowService windowService: IWindowService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IEnvironmentService environmentService: IEnvironmentService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService,
@ICommandService private commandService: ICommandService,
@IHistoryService historyService: IHistoryService
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@ICommandService private commandService: ICommandService
) {
super(id, label, windowService, environmentService, contextService, historyService);
super(id, label);
}
public run(): TPromise<any> {
@@ -245,7 +118,7 @@ export class GlobalRemoveRootFolderAction extends BaseWorkspacesAction {
// Workspace / Folder
if (state === WorkbenchState.WORKSPACE || state === WorkbenchState.FOLDER) {
return this.commandService.executeCommand<IWorkspaceFolder>(PICK_WORKSPACE_FOLDER_COMMAND).then(folder => {
return this.commandService.executeCommand<IWorkspaceFolder>(PICK_WORKSPACE_FOLDER_COMMAND_ID).then(folder => {
if (folder) {
return this.workspaceEditingService.removeFolders([folder.uri]).then(() => true);
}
@@ -258,82 +131,42 @@ export class GlobalRemoveRootFolderAction extends BaseWorkspacesAction {
}
}
export class RemoveRootFolderAction extends Action {
export class SaveWorkspaceAsAction extends Action {
static ID = 'workbench.action.removeRootFolder';
static LABEL = nls.localize('removeFolderFromWorkspace', "Remove Folder from Workspace");
constructor(
private rootUri: URI,
id: string,
label: string,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService
) {
super(id, label);
}
public run(): TPromise<any> {
return this.workspaceEditingService.removeFolders([this.rootUri]);
}
}
export class OpenFolderSettingsAction extends Action {
static ID = 'workbench.action.openFolderSettings';
static LABEL = nls.localize('openFolderSettings', "Open Folder Settings");
constructor(
private rootUri: URI,
id: string,
label: string,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@ICommandService private commandService: ICommandService
) {
super(id, label);
}
public run(): TPromise<any> {
const workspaceFolder = this.contextService.getWorkspaceFolder(this.rootUri);
return this.commandService.executeCommand('_workbench.action.openFolderSettings', workspaceFolder);
}
}
export class SaveWorkspaceAsAction extends BaseWorkspacesAction {
static ID = 'workbench.action.saveWorkspaceAs';
static readonly ID = 'workbench.action.saveWorkspaceAs';
static LABEL = nls.localize('saveWorkspaceAsAction', "Save Workspace As...");
constructor(
id: string,
label: string,
@IWindowService windowService: IWindowService,
@IEnvironmentService environmentService: IEnvironmentService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IWindowService private windowService: IWindowService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService,
@IHistoryService historyService: IHistoryService
@IHistoryService private historyService: IHistoryService
) {
super(id, label, windowService, environmentService, contextService, historyService);
super(id, label);
}
public run(): TPromise<any> {
const configPath = this.getNewWorkspaceConfigPath();
if (configPath) {
switch (this.contextService.getWorkbenchState()) {
case WorkbenchState.EMPTY:
case WorkbenchState.FOLDER:
const folders = this.contextService.getWorkspace().folders.map(folder => ({ uri: folder.uri }));
return this.workspaceEditingService.createAndEnterWorkspace(folders, configPath);
return this.getNewWorkspaceConfigPath().then(configPath => {
if (configPath) {
switch (this.contextService.getWorkbenchState()) {
case WorkbenchState.EMPTY:
case WorkbenchState.FOLDER:
const folders = this.contextService.getWorkspace().folders.map(folder => ({ uri: folder.uri }));
return this.workspaceEditingService.createAndEnterWorkspace(folders, configPath);
case WorkbenchState.WORKSPACE:
return this.workspaceEditingService.saveAndEnterWorkspace(configPath);
case WorkbenchState.WORKSPACE:
return this.workspaceEditingService.saveAndEnterWorkspace(configPath);
}
}
}
return TPromise.as(null);
return null;
});
}
private getNewWorkspaceConfigPath(): string {
private getNewWorkspaceConfigPath(): TPromise<string> {
return this.windowService.showSaveDialog({
buttonLabel: mnemonicButtonLabel(nls.localize({ key: 'save', comment: ['&& denotes a mnemonic'] }, "&&Save")),
title: nls.localize('saveWorkspace', "Save Workspace"),
@@ -345,7 +178,7 @@ export class SaveWorkspaceAsAction extends BaseWorkspacesAction {
export class OpenWorkspaceAction extends Action {
static ID = 'workbench.action.openWorkspace';
static readonly ID = 'workbench.action.openWorkspace';
static LABEL = nls.localize('openWorkspaceAction', "Open Workspace...");
constructor(
@@ -411,7 +244,7 @@ export class OpenFolderAsWorkspaceInNewWindowAction extends Action {
} else if (folders.length === 1) {
folderPromise = TPromise.as(folders[0]);
} else {
folderPromise = this.commandService.executeCommand<IWorkspaceFolder>(PICK_WORKSPACE_FOLDER_COMMAND);
folderPromise = this.commandService.executeCommand<IWorkspaceFolder>(PICK_WORKSPACE_FOLDER_COMMAND_ID);
}
return folderPromise.then(folder => {
@@ -426,65 +259,4 @@ export class OpenFolderAsWorkspaceInNewWindowAction extends Action {
});
});
}
}
export const PICK_WORKSPACE_FOLDER_COMMAND = '_workbench.pickWorkspaceFolder';
CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND, function (accessor: ServicesAccessor, args?: [IPickOptions, CancellationToken]) {
const contextService = accessor.get(IWorkspaceContextService);
const quickOpenService = accessor.get(IQuickOpenService);
const environmentService = accessor.get(IEnvironmentService);
const folders = contextService.getWorkspace().folders;
if (!folders.length) {
return void 0;
}
const folderPicks = folders.map(folder => {
return {
label: folder.name,
description: getPathLabel(resources.dirname(folder.uri), void 0, environmentService),
folder,
resource: folder.uri,
fileKind: FileKind.ROOT_FOLDER
} as IFilePickOpenEntry;
});
let options: IPickOptions;
if (args) {
options = args[0];
}
if (!options) {
options = Object.create(null);
}
if (!options.autoFocus) {
options.autoFocus = { autoFocusFirstEntry: true };
}
if (!options.placeHolder) {
options.placeHolder = nls.localize('workspaceFolderPickerPlaceholder', "Select workspace folder");
}
if (typeof options.matchOnDescription !== 'boolean') {
options.matchOnDescription = true;
}
let token: CancellationToken;
if (args) {
token = args[1];
}
if (!token) {
token = CancellationToken.None;
}
return quickOpenService.pick(folderPicks, options, token).then(pick => {
if (!pick) {
return void 0;
}
return folders[folderPicks.indexOf(pick)];
});
});
}

View File

@@ -0,0 +1,217 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import nls = require('vs/nls');
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import URI from 'vs/base/common/uri';
import * as resources from 'vs/base/common/resources';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { dirname } from 'vs/base/common/paths';
import { IQuickOpenService, IFilePickOpenEntry, IPickOptions } from 'vs/platform/quickOpen/common/quickOpen';
import { CancellationToken } from 'vs/base/common/cancellation';
import { mnemonicButtonLabel, getPathLabel } from 'vs/base/common/labels';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { FileKind, isParent } from 'vs/platform/files/common/files';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { isLinux } from 'vs/base/common/platform';
export const ADD_ROOT_FOLDER_COMMAND_ID = 'addRootFolder';
export const ADD_ROOT_FOLDER_LABEL = nls.localize('addFolderToWorkspace', "Add Folder to Workspace...");
export const PICK_WORKSPACE_FOLDER_COMMAND_ID = '_workbench.pickWorkspaceFolder';
function pickFolders(buttonLabel: string, title: string, windowService: IWindowService, contextService: IWorkspaceContextService, historyService: IHistoryService): TPromise<string[]> {
return windowService.showOpenDialog({
buttonLabel,
title,
properties: ['multiSelections', 'openDirectory', 'createDirectory'],
defaultPath: defaultFolderPath(contextService, historyService)
});
}
export function defaultFolderPath(contextService: IWorkspaceContextService, historyService: IHistoryService): string {
let candidate: URI;
// Check for last active file root first...
candidate = historyService.getLastActiveWorkspaceRoot('file');
// ...then for last active file
if (!candidate) {
candidate = historyService.getLastActiveFile();
}
return candidate ? dirname(candidate.fsPath) : void 0;
}
function services(accessor: ServicesAccessor): { windowService: IWindowService, historyService: IHistoryService, contextService: IWorkspaceContextService, environmentService: IEnvironmentService } {
return {
windowService: accessor.get(IWindowService),
historyService: accessor.get(IHistoryService),
contextService: accessor.get(IWorkspaceContextService),
environmentService: accessor.get(IEnvironmentService)
};
}
export function defaultFilePath(contextService: IWorkspaceContextService, historyService: IHistoryService): string {
let candidate: URI;
// Check for last active file first...
candidate = historyService.getLastActiveFile();
// ...then for last active file root
if (!candidate) {
candidate = historyService.getLastActiveWorkspaceRoot('file');
}
return candidate ? dirname(candidate.fsPath) : void 0;
}
export function defaultWorkspacePath(contextService: IWorkspaceContextService, historyService: IHistoryService, environmentService: IEnvironmentService): string {
// Check for current workspace config file first...
if (contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && !isUntitledWorkspace(contextService.getWorkspace().configuration.fsPath, environmentService)) {
return dirname(contextService.getWorkspace().configuration.fsPath);
}
// ...then fallback to default folder path
return defaultFolderPath(contextService, historyService);
}
function isUntitledWorkspace(path: string, environmentService: IEnvironmentService): boolean {
return isParent(path, environmentService.workspacesHome, !isLinux /* ignore case */);
}
// Command registration
CommandsRegistry.registerCommand({
id: 'workbench.action.files.openFileFolderInNewWindow',
handler: (accessor: ServicesAccessor) => {
const { windowService, historyService, contextService } = services(accessor);
windowService.pickFileFolderAndOpen({ forceNewWindow: true, dialogOptions: { defaultPath: defaultFilePath(contextService, historyService) } });
}
});
CommandsRegistry.registerCommand({
id: '_files.pickFolderAndOpen',
handler: (accessor: ServicesAccessor, forceNewWindow: boolean) => {
const { windowService, historyService, contextService } = services(accessor);
windowService.pickFolderAndOpen({ forceNewWindow, dialogOptions: { defaultPath: defaultFolderPath(contextService, historyService) } });
}
});
CommandsRegistry.registerCommand({
id: 'workbench.action.files.openFolderInNewWindow',
handler: (accessor: ServicesAccessor) => {
const { windowService, historyService, contextService } = services(accessor);
windowService.pickFolderAndOpen({ forceNewWindow: true, dialogOptions: { defaultPath: defaultFolderPath(contextService, historyService) } });
}
});
CommandsRegistry.registerCommand({
id: 'workbench.action.files.openFileInNewWindow',
handler: (accessor: ServicesAccessor) => {
const { windowService, historyService, contextService } = services(accessor);
windowService.pickFileAndOpen({ forceNewWindow: true, dialogOptions: { defaultPath: defaultFilePath(contextService, historyService) } });
}
});
CommandsRegistry.registerCommand({
id: 'workbench.action.openWorkspaceInNewWindow',
handler: (accessor: ServicesAccessor) => {
const { windowService, historyService, contextService, environmentService } = services(accessor);
windowService.pickWorkspaceAndOpen({ forceNewWindow: true, dialogOptions: { defaultPath: defaultWorkspacePath(contextService, historyService, environmentService) } });
}
});
CommandsRegistry.registerCommand({
id: ADD_ROOT_FOLDER_COMMAND_ID,
handler: (accessor) => {
const viewletService = accessor.get(IViewletService);
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
return pickFolders(mnemonicButtonLabel(nls.localize({ key: 'add', comment: ['&& denotes a mnemonic'] }, "&&Add")), nls.localize('addFolderToWorkspaceTitle', "Add Folder to Workspace"),
accessor.get(IWindowService), accessor.get(IWorkspaceContextService), accessor.get(IHistoryService)).then(folders => {
if (!folders || !folders.length) {
return null;
}
// Add and show Files Explorer viewlet
return workspaceEditingService.addFolders(folders.map(folder => ({ uri: URI.file(folder) })))
.then(() => viewletService.openViewlet(viewletService.getDefaultViewletId(), true))
.then(() => void 0);
});
}
});
CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (accessor, args?: [IPickOptions, CancellationToken]) {
const contextService = accessor.get(IWorkspaceContextService);
const quickOpenService = accessor.get(IQuickOpenService);
const environmentService = accessor.get(IEnvironmentService);
const folders = contextService.getWorkspace().folders;
if (!folders.length) {
return void 0;
}
const folderPicks = folders.map(folder => {
return {
label: folder.name,
description: getPathLabel(resources.dirname(folder.uri), void 0, environmentService),
folder,
resource: folder.uri,
fileKind: FileKind.ROOT_FOLDER
} as IFilePickOpenEntry;
});
let options: IPickOptions;
if (args) {
options = args[0];
}
if (!options) {
options = Object.create(null);
}
if (!options.autoFocus) {
options.autoFocus = { autoFocusFirstEntry: true };
}
if (!options.placeHolder) {
options.placeHolder = nls.localize('workspaceFolderPickerPlaceholder', "Select workspace folder");
}
if (typeof options.matchOnDescription !== 'boolean') {
options.matchOnDescription = true;
}
let token: CancellationToken;
if (args) {
token = args[1];
}
if (!token) {
token = CancellationToken.None;
}
return quickOpenService.pick(folderPicks, options, token).then(pick => {
if (!pick) {
return void 0;
}
return folders[folderPicks.indexOf(pick)];
});
});