Skip to content

Commit

Permalink
save workspace is always enabled (#34622)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 21, 2017
1 parent 845c25c commit 424e1eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
6 changes: 2 additions & 4 deletions src/vs/code/electron-main/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export class CodeMenu {

private closeFolder: Electron.MenuItem;
private closeWorkspace: Electron.MenuItem;
private saveWorkspaceAs: Electron.MenuItem;

private nativeTabMenuItems: Electron.MenuItem[];

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -443,7 +441,7 @@ export class CodeMenu {
openRecent,
isMultiRootEnabled ? __separator__() : null,
isMultiRootEnabled ? addFolder : null,
isMultiRootEnabled ? this.saveWorkspaceAs : null,
isMultiRootEnabled ? saveWorkspaceAs : null,
__separator__(),
saveFile,
saveFileAs,
Expand Down
13 changes: 3 additions & 10 deletions src/vs/workbench/browser/actions/workspaceActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -203,17 +203,10 @@ export class SaveWorkspaceAsAction extends BaseWorkspacesAction {
}

public run(): TPromise<any> {
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);
Expand Down

0 comments on commit 424e1eb

Please sign in to comment.