Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ILogService } from 'vs/platform/log/common/log';
import { IStorageService } from 'vs/platform/storage/node/storage';
import { IBackupMainService } from 'vs/platform/backup/common/backup';
import { BackupChannel } from 'vs/platform/backup/common/backupIpc';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IURLService } from 'vs/platform/url/common/url';
Expand Down Expand Up @@ -304,10 +302,6 @@ export class CodeApplication {
const urlChannel = appInstantiationService.createInstance(URLChannel, urlService);
this.electronIpcServer.registerChannel('url', urlChannel);

const backupService = accessor.get(IBackupMainService);
const backupChannel = appInstantiationService.createInstance(BackupChannel, backupService);
this.electronIpcServer.registerChannel('backup', backupChannel);

const windowsService = accessor.get(IWindowsService);
const windowsChannel = new WindowsChannel(windowsService);
this.electronIpcServer.registerChannel('windows', windowsChannel);
Expand Down
3 changes: 2 additions & 1 deletion src/vs/code/electron-main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ export class WindowsManager implements IWindowsMainService {

// Register window for backups
if (!configuration.extensionDevelopmentPath) {
this.backupService.registerWindowForBackupsSync(codeWindow.id, !configuration.workspacePath, options.emptyWorkspaceBackupFolder, configuration.workspacePath);
const backupPath = this.backupService.registerWindowForBackupsSync(codeWindow.id, !configuration.workspacePath, options.emptyWorkspaceBackupFolder, configuration.workspacePath);
configuration.backupPath = backupPath;
}

// Load it
Expand Down
12 changes: 2 additions & 10 deletions src/vs/platform/backup/common/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,19 @@
*--------------------------------------------------------------------------------------------*/

import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { TPromise } from 'vs/base/common/winjs.base';

export interface IBackupWorkspacesFormat {
folderWorkspaces: string[];
emptyWorkspaces: string[];
}

export const IBackupMainService = createDecorator<IBackupMainService>('backupMainService');
export const IBackupService = createDecorator<IBackupService>('backupService');

export interface IBackupMainService extends IBackupService {
export interface IBackupMainService {
_serviceBrand: any;

getWorkspaceBackupPaths(): string[];
getEmptyWorkspaceBackupPaths(): string[];

registerWindowForBackupsSync(windowId: number, isEmptyWorkspace: boolean, backupFolder?: string, workspacePath?: string): void;
}

export interface IBackupService {
_serviceBrand: any;

getBackupPath(windowId: number): TPromise<string>;
registerWindowForBackupsSync(windowId: number, isEmptyWorkspace: boolean, backupFolder?: string, workspacePath?: string): string;
}
38 changes: 0 additions & 38 deletions src/vs/platform/backup/common/backupIpc.ts

This file was deleted.

15 changes: 3 additions & 12 deletions src/vs/platform/backup/electron-main/backupMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { IBackupWorkspacesFormat, IBackupMainService } from 'vs/platform/backup/
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IFilesConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files';
import { TPromise } from 'vs/base/common/winjs.base';

export class BackupMainService implements IBackupMainService {

Expand All @@ -23,15 +22,13 @@ export class BackupMainService implements IBackupMainService {
protected workspacesJsonPath: string;

private backups: IBackupWorkspacesFormat;
private mapWindowToBackupFolder: { [windowId: number]: string; };

constructor(
@IEnvironmentService environmentService: IEnvironmentService,
@IConfigurationService private configurationService: IConfigurationService
) {
this.backupHome = environmentService.backupHome;
this.workspacesJsonPath = environmentService.backupWorkspacesPath;
this.mapWindowToBackupFolder = Object.create(null);

this.loadSync();
}
Expand All @@ -50,22 +47,16 @@ export class BackupMainService implements IBackupMainService {
return this.backups.emptyWorkspaces.slice(0); // return a copy
}

public getBackupPath(windowId: number): TPromise<string> {
if (!this.mapWindowToBackupFolder[windowId]) {
throw new Error(`Unknown backup workspace for window ${windowId}`);
}

return TPromise.as(path.join(this.backupHome, this.mapWindowToBackupFolder[windowId]));
}
public registerWindowForBackupsSync(windowId: number, isEmptyWorkspace: boolean, backupFolder?: string, workspacePath?: string): string {

public registerWindowForBackupsSync(windowId: number, isEmptyWorkspace: boolean, backupFolder?: string, workspacePath?: string): void {
// Generate a new folder if this is a new empty workspace
if (isEmptyWorkspace && !backupFolder) {
backupFolder = this.getRandomEmptyWorkspaceId();
}

this.mapWindowToBackupFolder[windowId] = isEmptyWorkspace ? backupFolder : this.getWorkspaceHash(workspacePath);
this.pushBackupPathsSync(isEmptyWorkspace ? backupFolder : workspacePath, isEmptyWorkspace);

return path.join(this.backupHome, isEmptyWorkspace ? backupFolder : this.getWorkspaceHash(workspacePath));
}

private pushBackupPathsSync(workspaceIdentifier: string, isEmptyWorkspace: boolean): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,33 +336,6 @@ suite('BackupMainService', () => {
});
});

suite('getBackupPath', () => {
test('should return the window\'s correct path', done => {
service.registerWindowForBackupsSync(1, false, null, fooFile.fsPath);
service.registerWindowForBackupsSync(2, true, 'test');
service.getBackupPath(1).then(window1Path => {
assert.equal(window1Path, service.toBackupPath(fooFile.fsPath));
service.getBackupPath(2).then(window2Path => {
assert.equal(window2Path, path.join(backupHome, 'test'));
done();
});
});
});

test('should override stale window paths with new paths', done => {
service.registerWindowForBackupsSync(1, false, null, fooFile.fsPath);
service.registerWindowForBackupsSync(1, false, null, barFile.fsPath);
service.getBackupPath(1).then(windowPath => {
assert.equal(windowPath, service.toBackupPath(barFile.fsPath));
done();
});
});

test('should throw when the window is not registered', () => {
assert.throws(() => service.getBackupPath(1));
});
});

suite('mixed path casing', () => {
test('should handle case insensitive paths properly (registerWindowForBackupsSync)', done => {
service.registerWindowForBackupsSync(1, false, null, fooFile.fsPath);
Expand Down
16 changes: 12 additions & 4 deletions src/vs/platform/windows/common/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export interface IWindowService {

export type MenuBarVisibility = 'default' | 'visible' | 'toggle' | 'hidden';

export interface IWindowConfiguration {
window: IWindowSettings;
}

export interface IWindowSettings {
openFilesInNewWindow: 'on' | 'off' | 'default';
openFoldersInNewWindow: 'on' | 'off' | 'default';
Expand Down Expand Up @@ -173,7 +177,13 @@ export interface IPath {
createFilePath?: boolean;
}

export interface IWindowConfiguration extends ParsedArgs {
export interface IOpenFileRequest {
filesToOpen?: IPath[];
filesToCreate?: IPath[];
filesToDiff?: IPath[];
}

export interface IWindowConfiguration extends ParsedArgs, IOpenFileRequest {
appRoot: string;
execPath: string;

Expand All @@ -196,9 +206,7 @@ export interface IWindowConfiguration extends ParsedArgs {

workspacePath?: string;

filesToOpen?: IPath[];
filesToCreate?: IPath[];
filesToDiff?: IPath[];
backupPath?: string;

nodeCachedDataDir: string;
}
22 changes: 0 additions & 22 deletions src/vs/workbench/electron-browser/common.ts

This file was deleted.

29 changes: 4 additions & 25 deletions src/vs/workbench/electron-browser/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,20 @@ import strings = require('vs/base/common/strings');
import { IResourceInput } from 'vs/platform/editor/common/editor';
import { WorkspaceContextService, Workspace } from 'vs/platform/workspace/common/workspace';
import { WorkspaceConfigurationService } from 'vs/workbench/services/configuration/node/configurationService';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { realpath, stat } from 'vs/base/node/pfs';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import path = require('path');
import gracefulFs = require('graceful-fs');
import { IPath, IOpenFileRequest } from 'vs/workbench/electron-browser/common';
import { IInitData } from 'vs/workbench/services/timer/common/timerService';
import { TimerService } from 'vs/workbench/services/timer/node/timerService';
import { KeyboardMapperFactory } from "vs/workbench/services/keybinding/electron-browser/keybindingService";
import { IWindowConfiguration, IPath } from "vs/platform/windows/common/windows";

import { webFrame } from 'electron';

import fs = require('fs');
gracefulFs.gracefulify(fs); // enable gracefulFs

export interface IWindowConfiguration extends ParsedArgs, IOpenFileRequest {

/**
* The physical keyboard is of ISO type (on OSX).
*/
isISOKeyboard?: boolean;

accessibilitySupport?: boolean;

appRoot: string;
execPath: string;

userEnv: any; /* vs/code/electron-main/env/IProcessEnvironment*/

workspacePath?: string;

zoomLevel?: number;
fullscreen?: boolean;
}

export function startup(configuration: IWindowConfiguration): TPromise<void> {

// Ensure others can listen to zoom level changes
Expand Down Expand Up @@ -148,8 +127,8 @@ function getWorkspace(workspacePath: string): TPromise<Workspace> {
});
}

function openWorkbench(environment: IWindowConfiguration, workspace: Workspace, options: IOptions): TPromise<void> {
const environmentService = new EnvironmentService(environment, environment.execPath);
function openWorkbench(configuration: IWindowConfiguration, workspace: Workspace, options: IOptions): TPromise<void> {
const environmentService = new EnvironmentService(configuration, configuration.execPath);
const configurationService = new WorkspaceConfigurationService(environmentService, workspace);
const contextService = new WorkspaceContextService(configurationService, workspace);
const timerService = new TimerService((<any>window).MonacoEnvironment.timers as IInitData, !contextService.hasWorkspace());
Expand All @@ -169,7 +148,7 @@ function openWorkbench(environment: IWindowConfiguration, workspace: Workspace,
contextService,
environmentService,
timerService
}, options);
}, configuration, options);
shell.open();

// Inform user about loading issues from the loader
Expand Down
13 changes: 5 additions & 8 deletions src/vs/workbench/electron-browser/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { resolveWorkbenchCommonProperties, getOrCreateMachineId } from 'vs/platf
import { machineIdIpcChannel } from 'vs/platform/telemetry/node/commonProperties';
import { WorkspaceStats } from 'vs/workbench/services/telemetry/common/workspaceStats';
import { IWindowIPCService, WindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { IWindowsService, IWindowService, IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { WindowsChannelClient } from 'vs/platform/windows/common/windowsIpc';
import { WindowService } from 'vs/platform/windows/electron-browser/windowService';
import { MessageService } from 'vs/workbench/services/message/electron-browser/messageService';
Expand Down Expand Up @@ -86,8 +86,6 @@ import { UpdateChannelClient } from 'vs/platform/update/common/updateIpc';
import { IUpdateService } from 'vs/platform/update/common/update';
import { URLChannelClient } from 'vs/platform/url/common/urlIpc';
import { IURLService } from 'vs/platform/url/common/url';
import { IBackupService } from 'vs/platform/backup/common/backup';
import { BackupChannelClient } from 'vs/platform/backup/common/backupIpc';
import { ExtensionHostProcessWorker } from 'vs/workbench/electron-browser/extensionHost';
import { ITimerService } from 'vs/workbench/services/timer/common/timerService';
import { remote, ipcRenderer as ipc } from 'electron';
Expand Down Expand Up @@ -141,12 +139,14 @@ export class WorkbenchShell {
private content: HTMLElement;
private contentsContainer: Builder;

private configuration: IWindowConfiguration;
private options: IOptions;
private workbench: Workbench;

constructor(container: HTMLElement, services: ICoreServices, options: IOptions) {
constructor(container: HTMLElement, services: ICoreServices, configuration: IWindowConfiguration, options: IOptions) {
this.container = container;

this.configuration = configuration;
this.options = options;

this.contextService = services.contextService;
Expand All @@ -170,7 +170,7 @@ export class WorkbenchShell {
const [instantiationService, serviceCollection] = this.initServiceCollection(parent.getHTMLElement());

// Workbench
this.workbench = instantiationService.createInstance(Workbench, parent.getHTMLElement(), workbenchContainer.getHTMLElement(), this.options, serviceCollection);
this.workbench = instantiationService.createInstance(Workbench, parent.getHTMLElement(), workbenchContainer.getHTMLElement(), this.configuration, this.options, serviceCollection);
this.workbench.startup({
onWorkbenchStarted: (info: IWorkbenchStartedInfo) => {

Expand Down Expand Up @@ -386,9 +386,6 @@ export class WorkbenchShell {
const urlChannel = mainProcessClient.getChannel('url');
serviceCollection.set(IURLService, new SyncDescriptor(URLChannelClient, urlChannel, this.windowIPCService.getWindowId()));

const backupChannel = mainProcessClient.getChannel('backup');
serviceCollection.set(IBackupService, new SyncDescriptor(BackupChannelClient, backupChannel));

return [instantiationService, serviceCollection];
}

Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/electron-browser/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ import { IWorkbenchEditorService, IResourceInputType } from 'vs/workbench/servic
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IMessageService } from 'vs/platform/message/common/message';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IWindowsService, IWindowService, IWindowSettings } from 'vs/platform/windows/common/windows';
import { IWindowsService, IWindowService, IWindowSettings, IWindowConfiguration, IPath, IOpenFileRequest } from 'vs/platform/windows/common/windows';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IPath, IOpenFileRequest, IWindowConfiguration } from 'vs/workbench/electron-browser/common';
import { IConfigurationEditingService, ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing';
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { IWorkbenchThemeService, VS_HC_THEME, VS_DARK_THEME } from 'vs/workbench/services/themes/common/workbenchThemeService';
Expand Down
Loading