From 424e1ebc28edbee570ffcee769410f00bd287500 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 21 Sep 2017 17:22:00 +0200 Subject: [PATCH] save workspace is always enabled (#34622) --- src/vs/code/electron-main/menus.ts | 6 ++---- .../workbench/browser/actions/workspaceActions.ts | 13 +++---------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index 032972aafc948..b796c7e82cd56 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -80,7 +80,6 @@ export class CodeMenu { private closeFolder: Electron.MenuItem; private closeWorkspace: Electron.MenuItem; - private saveWorkspaceAs: Electron.MenuItem; private nativeTabMenuItems: Electron.MenuItem[]; @@ -255,7 +254,6 @@ export class CodeMenu { this.closeWorkspace.visible = isInWorkspaceContext; this.closeFolder.visible = !isInWorkspaceContext; this.closeFolder.enabled = isInFolderContext; - this.saveWorkspaceAs.enabled = isInFolderContext || isInWorkspaceContext; } private install(): void { @@ -407,7 +405,7 @@ export class CodeMenu { const isMultiRootEnabled = (product.quality !== 'stable'); // TODO@Ben multi root - this.saveWorkspaceAs = this.createMenuItem(nls.localize({ key: 'miSaveWorkspaceAs', comment: ['&& denotes a mnemonic'] }, "&&Save Workspace As..."), 'workbench.action.saveWorkspaceAs'); + const saveWorkspaceAs = this.createMenuItem(nls.localize({ key: 'miSaveWorkspaceAs', comment: ['&& denotes a mnemonic'] }, "&&Save Workspace As..."), 'workbench.action.saveWorkspaceAs'); const addFolder = this.createMenuItem(nls.localize({ key: 'miAddFolderToWorkspace', comment: ['&& denotes a mnemonic'] }, "&&Add Folder to Workspace..."), 'workbench.action.addRootFolder'); const saveFile = this.createMenuItem(nls.localize({ key: 'miSave', comment: ['&& denotes a mnemonic'] }, "&&Save"), 'workbench.action.files.save'); @@ -443,7 +441,7 @@ export class CodeMenu { openRecent, isMultiRootEnabled ? __separator__() : null, isMultiRootEnabled ? addFolder : null, - isMultiRootEnabled ? this.saveWorkspaceAs : null, + isMultiRootEnabled ? saveWorkspaceAs : null, __separator__(), saveFile, saveFileAs, diff --git a/src/vs/workbench/browser/actions/workspaceActions.ts b/src/vs/workbench/browser/actions/workspaceActions.ts index 58f09abc65b3b..0989bcd541887 100644 --- a/src/vs/workbench/browser/actions/workspaceActions.ts +++ b/src/vs/workbench/browser/actions/workspaceActions.ts @@ -17,7 +17,7 @@ import URI from 'vs/base/common/uri'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { WORKSPACE_FILTER } from 'vs/platform/workspaces/common/workspaces'; -import { IMessageService, Severity } from 'vs/platform/message/common/message'; +import { IMessageService } from 'vs/platform/message/common/message'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { isLinux } from 'vs/base/common/platform'; import { dirname } from 'vs/base/common/paths'; @@ -203,17 +203,10 @@ export class SaveWorkspaceAsAction extends BaseWorkspacesAction { } public run(): TPromise { - const workspaceState = this.contextService.getWorkbenchState(); - if (workspaceState === WorkbenchState.EMPTY) { - this.messageService.show(Severity.Info, nls.localize('saveEmptyWorkspaceNotSupported', "Please open a workspace first to save.")); - - return TPromise.as(null); - } - const configPath = this.getNewWorkspaceConfigPath(); if (configPath) { - switch (workspaceState) { - + switch (this.contextService.getWorkbenchState()) { + case WorkbenchState.EMPTY: case WorkbenchState.FOLDER: const workspaceFolders = this.contextService.getWorkspace().folders.map(root => root.uri.fsPath); return this.workspaceEditingService.createAndEnterWorkspace(workspaceFolders, configPath);