Merge from vscode 5b9869eb02fa4c96205a74d05cad9164dfd06d60 (#5607)

This commit is contained in:
Anthony Dresser
2019-05-24 12:20:30 -07:00
committed by GitHub
parent 361ada4963
commit bcc449b524
126 changed files with 3096 additions and 2255 deletions

View File

@@ -302,6 +302,24 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.collapseAll',
weight: KeybindingWeight.WorkbenchContrib,
when: WorkbenchListFocusContextKey,
primary: KeyMod.CtrlCmd | KeyCode.LeftArrow,
mac: {
primary: KeyMod.CtrlCmd | KeyCode.LeftArrow,
secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow]
},
handler: (accessor) => {
const focusedTree = accessor.get(IListService).lastFocusedList;
if (focusedTree && !(focusedTree instanceof List || focusedTree instanceof PagedList)) {
focusedTree.collapseAll();
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.expand',
weight: KeybindingWeight.WorkbenchContrib,

View File

@@ -73,7 +73,7 @@ abstract class BaseNavigationAction extends Action {
return this.panelService.openPanel(activePanelId, true)!;
}
protected navigateToSidebar(): Promise<IViewlet | boolean> {
protected async navigateToSidebar(): Promise<IViewlet | boolean> {
if (!this.layoutService.isVisible(Parts.SIDEBAR_PART)) {
return Promise.resolve(false);
}
@@ -84,8 +84,8 @@ abstract class BaseNavigationAction extends Action {
}
const activeViewletId = activeViewlet.getId();
return this.viewletService.openViewlet(activeViewletId, true)
.then(value => value === null ? false : value);
const value = await this.viewletService.openViewlet(activeViewletId, true);
return value === null ? false : value;
}
protected navigateAcrossEditorGroup(direction: GroupDirection): boolean {

View File

@@ -160,21 +160,18 @@ export class GlobalRemoveRootFolderAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
const state = this.contextService.getWorkbenchState();
// Workspace / Folder
if (state === WorkbenchState.WORKSPACE || state === WorkbenchState.FOLDER) {
return this.commandService.executeCommand<IWorkspaceFolder>(PICK_WORKSPACE_FOLDER_COMMAND_ID).then(folder => {
if (folder) {
return this.workspaceEditingService.removeFolders([folder.uri]).then(() => true);
}
return true;
});
const folder = await this.commandService.executeCommand<IWorkspaceFolder>(PICK_WORKSPACE_FOLDER_COMMAND_ID);
if (folder) {
await this.workspaceEditingService.removeFolders([folder.uri]);
}
}
return Promise.resolve(true);
return true;
}
}
@@ -193,20 +190,18 @@ export class SaveWorkspaceAsAction extends Action {
super(id, label);
}
run(): Promise<any> {
return this.workspaceEditingService.pickNewWorkspacePath().then((configPathUri): Promise<void> | void => {
if (configPathUri) {
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, configPathUri);
case WorkbenchState.WORKSPACE:
return this.workspaceEditingService.saveAndEnterWorkspace(configPathUri);
}
async run(): Promise<any> {
const configPathUri = await this.workspaceEditingService.pickNewWorkspacePath();
if (configPathUri) {
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, configPathUri);
case WorkbenchState.WORKSPACE:
return this.workspaceEditingService.saveAndEnterWorkspace(configPathUri);
}
});
}
}
}
@@ -296,14 +291,13 @@ export class DuplicateWorkspaceInNewWindowAction extends Action {
super(id, label);
}
run(): Promise<any> {
async run(): Promise<any> {
const folders = this.workspaceContextService.getWorkspace().folders;
const remoteAuthority = this.environmentService.configuration.remoteAuthority;
return this.workspacesService.createUntitledWorkspace(folders, remoteAuthority).then(newWorkspace => {
return this.workspaceEditingService.copyWorkspaceSettings(newWorkspace).then(() => {
return this.windowService.openWindow([{ workspaceUri: newWorkspace.configPath }], { forceNewWindow: true });
});
});
const newWorkspace = await this.workspacesService.createUntitledWorkspace(folders, remoteAuthority);
await this.workspaceEditingService.copyWorkspaceSettings(newWorkspace);
return this.windowService.openWindow([{ workspaceUri: newWorkspace.configPath }], { forceNewWindow: true });
}
}

View File

@@ -54,30 +54,28 @@ CommandsRegistry.registerCommand({
CommandsRegistry.registerCommand({
id: ADD_ROOT_FOLDER_COMMAND_ID,
handler: (accessor) => {
handler: async (accessor) => {
const viewletService = accessor.get(IViewletService);
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
const dialogsService = accessor.get(IFileDialogService);
return dialogsService.showOpenDialog({
const folders = await 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()
}).then((folders): Promise<any> | null => {
if (!folders || !folders.length) {
return null;
}
// Add and show Files Explorer viewlet
return workspaceEditingService.addFolders(folders.map(folder => ({ uri: resources.removeTrailingPathSeparator(folder) })))
.then(() => viewletService.openViewlet(viewletService.getDefaultViewletId(), true))
.then(() => undefined);
});
if (!folders || !folders.length) {
return;
}
await workspaceEditingService.addFolders(folders.map(folder => ({ uri: resources.removeTrailingPathSeparator(folder) })));
await viewletService.openViewlet(viewletService.getDefaultViewletId(), true);
}
});
CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (accessor, args?: [IPickOptions<IQuickPickItem>, CancellationToken]) {
CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, async function (accessor, args?: [IPickOptions<IQuickPickItem>, CancellationToken]) {
const quickInputService = accessor.get(IQuickInputService);
const labelService = accessor.get(ILabelService);
const contextService = accessor.get(IWorkspaceContextService);
@@ -86,7 +84,7 @@ CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (acc
const folders = contextService.getWorkspace().folders;
if (!folders.length) {
return undefined;
return undefined; // {{SQL CARBON EDIT}} @anthonydresser strict-null-check
}
const folderPicks: IQuickPickItem[] = folders.map(folder => {
@@ -113,12 +111,11 @@ CommandsRegistry.registerCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, function (acc
}
const token: CancellationToken = (args ? args[1] : undefined) || CancellationToken.None;
const pick = await quickInputService.pick(folderPicks, options, token);
return quickInputService.pick(folderPicks, options, token).then(pick => {
if (!pick) {
return undefined;
}
if (pick) {
return folders[folderPicks.indexOf(pick)];
});
}
return undefined; // {{SQL CARBON EDIT}} @anthonydresser strict-null-check
});