mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -2,9 +2,7 @@
|
||||
* 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 * as nls from 'vs/nls';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
@@ -31,7 +29,7 @@ export class ToggleActivityBarVisibilityAction extends Action {
|
||||
this.enabled = !!this.partService;
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Promise<any> {
|
||||
const visibility = this.partService.isVisible(Parts.ACTIVITYBAR_PART);
|
||||
const newVisibilityValue = !visibility;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as nls from 'vs/nls';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
@@ -25,10 +24,10 @@ class ToggleCenteredLayout extends Action {
|
||||
this.enabled = !!this.partService;
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Promise<any> {
|
||||
this.partService.centerEditorLayout(!this.partService.isEditorLayoutCentered());
|
||||
|
||||
return TPromise.as(null);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,12 +42,3 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
|
||||
},
|
||||
order: 3
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarLayoutMenu, {
|
||||
group: '2_layouts',
|
||||
command: {
|
||||
id: 'workbench.action.editorLayoutCentered',
|
||||
title: nls.localize({ key: 'miCenteredEditorLayout', comment: ['&& denotes a mnemonic'] }, "&&Centered")
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
* 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 'vs/css!./media/actions';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as nls from 'vs/nls';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
@@ -48,11 +46,11 @@ export class ToggleEditorLayoutAction extends Action {
|
||||
this.enabled = this.editorGroupService.count > 1;
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Promise<any> {
|
||||
const newOrientation = (this.editorGroupService.orientation === GroupOrientation.VERTICAL) ? GroupOrientation.HORIZONTAL : GroupOrientation.VERTICAL;
|
||||
this.editorGroupService.setGroupOrientation(newOrientation);
|
||||
|
||||
return TPromise.as(null);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
@@ -68,7 +66,7 @@ CommandsRegistry.registerCommand('_workbench.editor.setGroupOrientation', functi
|
||||
|
||||
editorGroupService.setGroupOrientation(orientation);
|
||||
|
||||
return TPromise.as<void>(null);
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
|
||||
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* 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 * as nls from 'vs/nls';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
@@ -31,12 +29,16 @@ export class ToggleSidebarPositionAction extends Action {
|
||||
this.enabled = !!this.partService && !!this.configurationService;
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Promise<any> {
|
||||
const position = this.partService.getSideBarPosition();
|
||||
const newPositionValue = (position === Position.LEFT) ? 'right' : 'left';
|
||||
|
||||
return this.configurationService.updateValue(ToggleSidebarPositionAction.sidebarPositionConfigurationKey, newPositionValue, ConfigurationTarget.USER);
|
||||
}
|
||||
|
||||
static getLabel(partService: IPartService): string {
|
||||
return partService.getSideBarPosition() === Position.LEFT ? nls.localize('moveSidebarRight', "Move Side Bar Right") : nls.localize('moveSidebarLeft', "Move Side Bar Left");
|
||||
}
|
||||
}
|
||||
|
||||
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* 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 * as nls from 'vs/nls';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
@@ -28,9 +26,11 @@ export class ToggleSidebarVisibilityAction extends Action {
|
||||
this.enabled = !!this.partService;
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Thenable<any> {
|
||||
const hideSidebar = this.partService.isVisible(Parts.SIDEBAR_PART);
|
||||
return this.partService.setSideBarHidden(hideSidebar);
|
||||
this.partService.setSideBarHidden(hideSidebar);
|
||||
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* 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 * as nls from 'vs/nls';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
@@ -31,7 +29,7 @@ export class ToggleStatusbarVisibilityAction extends Action {
|
||||
this.enabled = !!this.partService;
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Promise<any> {
|
||||
const visibility = this.partService.isVisible(Parts.STATUSBAR_PART);
|
||||
const newVisibilityValue = !visibility;
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* 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 * as nls from 'vs/nls';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
@@ -28,7 +26,7 @@ export class ToggleTabsVisibilityAction extends Action {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Promise<any> {
|
||||
const visibility = this.configurationService.getValue<string>(ToggleTabsVisibilityAction.tabsVisibleKey);
|
||||
const newVisibilityValue = !visibility;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as nls from 'vs/nls';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { KeyCode, KeyMod, KeyChord } from 'vs/base/common/keyCodes';
|
||||
@@ -26,9 +25,10 @@ class ToggleZenMode extends Action {
|
||||
this.enabled = !!this.partService;
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Promise<any> {
|
||||
this.partService.toggleZenMode();
|
||||
return TPromise.as(null);
|
||||
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
* 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 { Action } from 'vs/base/common/actions';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
@@ -13,13 +10,13 @@ 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 { WORKSPACE_FILTER, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { mnemonicButtonLabel } from 'vs/base/common/labels';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
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';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL, PICK_WORKSPACE_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
|
||||
export class OpenFileAction extends Action {
|
||||
|
||||
@@ -29,15 +26,13 @@ export class OpenFileAction extends Action {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWindowService private windowService: IWindowService,
|
||||
@IHistoryService private historyService: IHistoryService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService
|
||||
@IFileDialogService private dialogService: IFileDialogService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(event?: any, data?: ITelemetryData): TPromise<any> {
|
||||
return this.windowService.pickFileAndOpen({ telemetryExtraData: data, dialogOptions: { defaultPath: defaultFilePath(this.contextService, this.historyService) } });
|
||||
run(event?: any, data?: ITelemetryData): Thenable<any> {
|
||||
return this.dialogService.pickFileAndOpen({ forceNewWindow: false, telemetryExtraData: data });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,15 +44,13 @@ export class OpenFolderAction extends Action {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWindowService private windowService: IWindowService,
|
||||
@IHistoryService private historyService: IHistoryService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService
|
||||
@IFileDialogService private dialogService: IFileDialogService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(event?: any, data?: ITelemetryData): TPromise<any> {
|
||||
return this.windowService.pickFolderAndOpen({ telemetryExtraData: data, dialogOptions: { defaultPath: defaultFolderPath(this.contextService, this.historyService) } });
|
||||
run(event?: any, data?: ITelemetryData): Thenable<any> {
|
||||
return this.dialogService.pickFolderAndOpen({ forceNewWindow: false, telemetryExtraData: data });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,15 +62,13 @@ export class OpenFileFolderAction extends Action {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWindowService private windowService: IWindowService,
|
||||
@IHistoryService private historyService: IHistoryService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService
|
||||
@IFileDialogService private dialogService: IFileDialogService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(event?: any, data?: ITelemetryData): TPromise<any> {
|
||||
return this.windowService.pickFileFolderAndOpen({ telemetryExtraData: data, dialogOptions: { defaultPath: defaultFilePath(this.contextService, this.historyService) } });
|
||||
run(event?: any, data?: ITelemetryData): Thenable<any> {
|
||||
return this.dialogService.pickFileFolderAndOpen({ forceNewWindow: false, telemetryExtraData: data });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +85,7 @@ export class AddRootFolderAction extends Action {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Thenable<any> {
|
||||
return this.commandService.executeCommand(ADD_ROOT_FOLDER_COMMAND_ID);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +105,7 @@ export class GlobalRemoveRootFolderAction extends Action {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Thenable<any> {
|
||||
const state = this.contextService.getWorkbenchState();
|
||||
|
||||
// Workspace / Folder
|
||||
@@ -128,7 +119,7 @@ export class GlobalRemoveRootFolderAction extends Action {
|
||||
});
|
||||
}
|
||||
|
||||
return TPromise.as(true);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,18 +131,18 @@ export class SaveWorkspaceAsAction extends Action {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWindowService private windowService: IWindowService,
|
||||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService,
|
||||
@IHistoryService private historyService: IHistoryService
|
||||
@IFileDialogService private dialogService: IFileDialogService
|
||||
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
return this.getNewWorkspaceConfigPath().then(configPath => {
|
||||
if (configPath) {
|
||||
run(): Thenable<any> {
|
||||
return this.getNewWorkspaceConfigPath().then(configPathUri => {
|
||||
if (configPathUri) {
|
||||
const configPath = configPathUri.fsPath;
|
||||
switch (this.contextService.getWorkbenchState()) {
|
||||
case WorkbenchState.EMPTY:
|
||||
case WorkbenchState.FOLDER:
|
||||
@@ -167,12 +158,12 @@ export class SaveWorkspaceAsAction extends Action {
|
||||
});
|
||||
}
|
||||
|
||||
private getNewWorkspaceConfigPath(): TPromise<string> {
|
||||
return this.windowService.showSaveDialog({
|
||||
buttonLabel: mnemonicButtonLabel(nls.localize({ key: 'save', comment: ['&& denotes a mnemonic'] }, "&&Save")),
|
||||
private getNewWorkspaceConfigPath(): Thenable<URI> {
|
||||
return this.dialogService.showSaveDialog({
|
||||
saveLabel: mnemonicButtonLabel(nls.localize({ key: 'save', comment: ['&& denotes a mnemonic'] }, "&&Save")),
|
||||
title: nls.localize('saveWorkspace', "Save Workspace"),
|
||||
filters: WORKSPACE_FILTER,
|
||||
defaultPath: defaultWorkspacePath(this.contextService, this.historyService, this.environmentService)
|
||||
defaultUri: this.dialogService.defaultWorkspacePath(Schemas.file)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -185,16 +176,13 @@ export class OpenWorkspaceAction extends Action {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWindowService private windowService: IWindowService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IHistoryService private historyService: IHistoryService,
|
||||
@IEnvironmentService private environmentService: IEnvironmentService
|
||||
@IFileDialogService private dialogService: IFileDialogService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(event?: any, data?: ITelemetryData): TPromise<any> {
|
||||
return this.windowService.pickWorkspaceAndOpen({ telemetryExtraData: data, dialogOptions: { defaultPath: defaultWorkspacePath(this.contextService, this.historyService, this.environmentService) } });
|
||||
run(event?: any, data?: ITelemetryData): Thenable<any> {
|
||||
return this.dialogService.pickWorkspaceAndOpen({ telemetryExtraData: data });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +202,7 @@ export class OpenWorkspaceConfigFileAction extends Action {
|
||||
this.enabled = !!this.workspaceContextService.getWorkspace().configuration;
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Thenable<any> {
|
||||
return this.editorService.openEditor({ resource: this.workspaceContextService.getWorkspace().configuration });
|
||||
}
|
||||
}
|
||||
@@ -235,7 +223,7 @@ export class DuplicateWorkspaceInNewWindowAction extends Action {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Thenable<any> {
|
||||
const folders = this.workspaceContextService.getWorkspace().folders;
|
||||
|
||||
return this.workspacesService.createWorkspace(folders).then(newWorkspace => {
|
||||
|
||||
@@ -3,140 +3,54 @@
|
||||
* 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 * as nls from 'vs/nls';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { IWorkspaceContextService } 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 } 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 { FileKind } from 'vs/platform/files/common/files';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { IUriDisplayService } from 'vs/platform/uriDisplay/common/uriDisplay';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IQuickInputService, IPickOptions, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { getIconClasses } from 'vs/editor/common/services/getIconClasses';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
|
||||
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) } });
|
||||
}
|
||||
handler: (accessor: ServicesAccessor) => accessor.get(IFileDialogService).pickFileFolderAndOpen({ forceNewWindow: true })
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: '_files.pickFolderAndOpen',
|
||||
handler: (accessor: ServicesAccessor, forceNewWindow: boolean) => {
|
||||
const { windowService, historyService, contextService } = services(accessor);
|
||||
|
||||
windowService.pickFolderAndOpen({ forceNewWindow, dialogOptions: { defaultPath: defaultFolderPath(contextService, historyService) } });
|
||||
}
|
||||
handler: (accessor: ServicesAccessor, forceNewWindow: boolean) => accessor.get(IFileDialogService).pickFolderAndOpen({ forceNewWindow })
|
||||
});
|
||||
|
||||
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) } });
|
||||
}
|
||||
handler: (accessor: ServicesAccessor) => accessor.get(IFileDialogService).pickFolderAndOpen({ forceNewWindow: true })
|
||||
});
|
||||
|
||||
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) } });
|
||||
}
|
||||
handler: (accessor: ServicesAccessor) => accessor.get(IFileDialogService).pickFileAndOpen({ forceNewWindow: true })
|
||||
});
|
||||
|
||||
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) } });
|
||||
}
|
||||
handler: (accessor: ServicesAccessor) => accessor.get(IFileDialogService).pickWorkspaceAndOpen({ forceNewWindow: true })
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
@@ -144,24 +58,32 @@ CommandsRegistry.registerCommand({
|
||||
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;
|
||||
}
|
||||
const dialogsService = accessor.get(IFileDialogService);
|
||||
return dialogsService.showOpenDialog({
|
||||
openLabel: mnemonicButtonLabel(nls.localize({ key: 'add', comment: ['&& denotes a mnemonic'] }, "&&Add")),
|
||||
title: nls.localize('addFolderToWorkspaceTitle', "Add Folder to Workspace"),
|
||||
canSelectFolders: true,
|
||||
canSelectMany: true,
|
||||
defaultUri: dialogsService.defaultFolderPath(Schemas.file)
|
||||
}).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);
|
||||
});
|
||||
// Add and show Files Explorer viewlet
|
||||
return workspaceEditingService.addFolders(folders.map(folder => ({ uri: folder })))
|
||||
.then(() => viewletService.openViewlet(viewletService.getDefaultViewletId(), true))
|
||||
.then(() => void 0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (accessor, args?: [IPickOptions, CancellationToken]) {
|
||||
const quickOpenService = accessor.get(IQuickOpenService);
|
||||
const uriDisplayService = accessor.get(IUriDisplayService);
|
||||
CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (accessor, args?: [IPickOptions<IQuickPickItem>, CancellationToken]) {
|
||||
const quickInputService = accessor.get(IQuickInputService);
|
||||
const labelService = accessor.get(ILabelService);
|
||||
const contextService = accessor.get(IWorkspaceContextService);
|
||||
const modelService = accessor.get(IModelService);
|
||||
const modeService = accessor.get(IModeService);
|
||||
|
||||
const folders = contextService.getWorkspace().folders;
|
||||
if (!folders.length) {
|
||||
@@ -171,14 +93,13 @@ CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (acc
|
||||
const folderPicks = folders.map(folder => {
|
||||
return {
|
||||
label: folder.name,
|
||||
description: uriDisplayService.getLabel(resources.dirname(folder.uri), true),
|
||||
description: labelService.getUriLabel(resources.dirname(folder.uri), { relative: true }),
|
||||
folder,
|
||||
resource: folder.uri,
|
||||
fileKind: FileKind.ROOT_FOLDER
|
||||
} as IFilePickOpenEntry;
|
||||
iconClasses: getIconClasses(modelService, modeService, folder.uri, FileKind.ROOT_FOLDER)
|
||||
} as IQuickPickItem;
|
||||
});
|
||||
|
||||
let options: IPickOptions;
|
||||
let options: IPickOptions<IQuickPickItem>;
|
||||
if (args) {
|
||||
options = args[0];
|
||||
}
|
||||
@@ -187,8 +108,8 @@ CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (acc
|
||||
options = Object.create(null);
|
||||
}
|
||||
|
||||
if (!options.autoFocus) {
|
||||
options.autoFocus = { autoFocusFirstEntry: true };
|
||||
if (!options.activeItem) {
|
||||
options.activeItem = folderPicks[0];
|
||||
}
|
||||
|
||||
if (!options.placeHolder) {
|
||||
@@ -208,7 +129,7 @@ CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (acc
|
||||
token = CancellationToken.None;
|
||||
}
|
||||
|
||||
return quickOpenService.pick(folderPicks, options, token).then(pick => {
|
||||
return quickInputService.pick(folderPicks, options, token).then(pick => {
|
||||
if (!pick) {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user