Skip to content

Commit

Permalink
Update to Electron 0.37.x (#2559)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Apr 13, 2016
1 parent 96c3dbc commit 84abe71
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 48 deletions.
16 changes: 8 additions & 8 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Code",
"version": "1.0.0",
"electronVersion": "0.35.6",
"electronVersion": "0.37.5",
"author": {
"name": "Microsoft Corporation"
},
Expand Down
6 changes: 4 additions & 2 deletions src/typings/electron.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,7 @@ declare module Electron {
icon?: NativeImage;
noLink?: boolean;
cancelId?: number;
defaultId?: number;
}
}

Expand Down Expand Up @@ -1797,8 +1798,8 @@ declare module Electron {
}

class Session {
static fromPartition(partition: string): Session;
static defaultSession: Session;
fromPartition(partition: string): Session;
defaultSession: Session;

cookies: any;
clearCache(callback: Function): void;
Expand All @@ -1811,6 +1812,7 @@ declare module Electron {
disableNetworkEmulation(): void;
setCertificateVerifyProc(proc: CertificateVerifyProc): void;
webRequest: any;
flushStorageData(): void;
}

interface CommonElectron {
Expand Down
13 changes: 1 addition & 12 deletions src/vs/base/browser/ui/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class BaseDropdown extends ActionRunner {
e.preventDefault();
e.stopPropagation();

this.toggleDropdown();
this.show();
}).appendTo(this.$el);

let cleanupFn = labelRenderer(this.$label.getHTMLElement());
Expand All @@ -96,14 +96,6 @@ export class BaseDropdown extends ActionRunner {
this.$label.title(tooltip);
}

/*protected*/ toggleDropdown(): void {
if (this.$el.hasClass('active')) {
this.hide();
} else {
this.show();
}
}

/*protected*/ show(): void {
// noop
}
Expand Down Expand Up @@ -219,7 +211,6 @@ export class DropdownMenu extends BaseDropdown {

/*protected*/ _contextMenuProvider: IContextMenuProvider;
private _menuOptions: IMenuOptions;
/*protected*/ currentContainer: HTMLElement;
/*protected*/ _actions: IAction[];
/*protected*/ actionProvider: IActionProvider;
private menuClassName: string;
Expand All @@ -228,7 +219,6 @@ export class DropdownMenu extends BaseDropdown {
super(container, options);

this._contextMenuProvider = options.contextMenuProvider;
this.currentContainer = null;
this.actions = options.actions || [];
this.actionProvider = options.actionProvider;
this.menuClassName = options.menuClassName || '';
Expand Down Expand Up @@ -273,7 +263,6 @@ export class DropdownMenu extends BaseDropdown {
getMenuClassName: () => this.menuClassName,
onHide: () => {
this.$el.removeClass('active');
this.currentContainer = null;
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHostDocuments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,4 +670,4 @@ export class MainThreadDocuments {
}
}, onUnexpectedError);
}
}
}
7 changes: 7 additions & 0 deletions src/vs/workbench/electron-main/update-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ export class UpdateManager extends events.EventEmitter {
return;
}

// for some reason updating on Mac causes the local storage not to be flushed.
// we workaround this issue by forcing an explicit flush of the storage data.
// see also https://github.com/Microsoft/vscode/issues/172
if (platform.isMacintosh) {
electron.session.defaultSession.flushStorageData();
}

rawQuitAndUpdate();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class VSCodeWindow {

// For VS theme we can show directly because background is white
const usesLightTheme = /vs($| )/.test(storage.getItem<string>(VSCodeWindow.themeStorageKey));
let showDirectly = usesLightTheme;
let showDirectly = true; // set to false to prevent background color flash (flash should be fixed for Electron >= 0.37.x)
if (showDirectly && !global.windowShow) {
global.windowShow = new Date().getTime();
}
Expand Down
17 changes: 12 additions & 5 deletions src/vs/workbench/parts/files/electron-browser/textFileServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import nls = require('vs/nls');
import {TPromise} from 'vs/base/common/winjs.base';
import paths = require('vs/base/common/paths');
import strings = require('vs/base/common/strings');
import {isWindows} from 'vs/base/common/platform';
import {isWindows, isLinux} from 'vs/base/common/platform';
import URI from 'vs/base/common/uri';
import {UntitledEditorModel} from 'vs/workbench/common/editor/untitledEditorModel';
import {IEventService} from 'vs/platform/event/common/event';
Expand Down Expand Up @@ -165,17 +165,20 @@ export class TextFileService extends AbstractTextFileService {

// Button order
// Windows: Save | Don't Save | Cancel
// Mac/Linux: Save | Cancel | Don't
// Mac: Save | Cancel | Don't Save
// Linux: Don't Save | Cancel | Save

const save = { label: resourcesToConfirm.length > 1 ? this.mnemonicLabel(nls.localize({ key: 'saveAll', comment: ['&& denotes a mnemonic'] }, "&&Save All")) : this.mnemonicLabel(nls.localize({ key: 'save', comment: ['&& denotes a mnemonic'] }, "&&Save")), result: ConfirmResult.SAVE };
const dontSave = { label: this.mnemonicLabel(nls.localize({ key: 'dontSave', comment: ['&& denotes a mnemonic'] }, "Do&&n't Save")), result: ConfirmResult.DONT_SAVE };
const cancel = { label: nls.localize('cancel', "Cancel"), result: ConfirmResult.CANCEL };

const buttons = [save];
const buttons = [];
if (isWindows) {
buttons.push(dontSave, cancel);
buttons.push(save, dontSave, cancel);
} else if (isLinux) {
buttons.push(dontSave, cancel, save);
} else {
buttons.push(cancel, dontSave);
buttons.push(save, cancel, dontSave);
}

let opts: Electron.Dialog.ShowMessageBoxOptions = {
Expand All @@ -188,6 +191,10 @@ export class TextFileService extends AbstractTextFileService {
cancelId: buttons.indexOf(cancel)
};

if (isLinux) {
opts.defaultId = 2;
}

const choice = this.windowService.getWindow().showMessageBox(opts);

return buttons[choice].result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import {TPromise} from 'vs/base/common/winjs.base';
import severity from 'vs/base/common/severity';
import actions = require('vs/base/common/actions');
import {IAction} from 'vs/base/common/actions';
import {Separator} from 'vs/base/browser/ui/actionbar/actionbar';
import dom = require('vs/base/browser/dom');
import {$} from 'vs/base/browser/builder';
Expand Down Expand Up @@ -40,7 +40,6 @@ export class ContextMenuService implements IContextMenuService {

return TPromise.timeout(0).then(() => { // https://github.com/Microsoft/vscode/issues/3638
let menu = new remote.Menu();
let actionToRun: actions.IAction = null;

actions.forEach(a => {
if (a instanceof Separator) {
Expand All @@ -55,7 +54,7 @@ export class ContextMenuService implements IContextMenuService {
accelerator,
enabled: a.enabled,
click: () => {
actionToRun = a;
this.runAction(a, delegate);
}
});

Expand Down Expand Up @@ -84,21 +83,20 @@ export class ContextMenuService implements IContextMenuService {
y *= zoom;

menu.popup(remote.getCurrentWindow(), Math.floor(x), Math.floor(y));
});
});
}

if (delegate.onHide) {
delegate.onHide(false);
}
private runAction(actionToRun: IAction, delegate: IContextMenuDelegate): void {
if (delegate.onHide) {
delegate.onHide(false);
}

if (!actionToRun) {
return;
}
this.telemetryService.publicLog('workbenchActionExecuted', { id: actionToRun.id, from: 'contextMenu' });

this.telemetryService.publicLog('workbenchActionExecuted', { id: actionToRun.id, from: 'contextMenu' });
const context = delegate.getActionsContext ? delegate.getActionsContext() : null;
const res = actionToRun.run(context) || TPromise.as(null);

const context = delegate.getActionsContext ? delegate.getActionsContext() : null;
return actionToRun.run(context) || TPromise.as(null);
});
})
.done(null, e => this.messageService.show(severity.Error, e));
res.done(null, e => this.messageService.show(severity.Error, e));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {IWindowService} from 'vs/workbench/services/window/electron-browser/wind
import nls = require('vs/nls');
import {WorkbenchMessageService} from 'vs/workbench/services/message/browser/messageService';
import {IConfirmation} from 'vs/platform/message/common/message';
import {isWindows} from 'vs/base/common/platform';
import {isWindows, isLinux} from 'vs/base/common/platform';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
Expand Down Expand Up @@ -38,19 +38,27 @@ export class MessageService extends WorkbenchMessageService {
title: confirmation.title || this.contextService.getConfiguration().env.appName,
message: confirmation.message,
buttons: [
this.mnemonicLabel(confirmation.primaryButton),
this.mnemonicLabel(confirmation.secondaryButton)
isLinux ? this.mnemonicLabel(confirmation.secondaryButton) : this.mnemonicLabel(confirmation.primaryButton),
isLinux ? this.mnemonicLabel(confirmation.primaryButton) : this.mnemonicLabel(confirmation.secondaryButton)
],
noLink: true,
cancelId: 1
};

if (isLinux) {
opts.defaultId = 1; // Linux: buttons are swapped
}

if (confirmation.detail) {
opts.detail = confirmation.detail;
}

let result = this.windowService.getWindow().showMessageBox(opts);

if (isLinux) {
return result === 1 ? true : false; // Linux: buttons are swapped
}

return result === 0 ? true : false;
}

Expand Down

0 comments on commit 84abe71

Please sign in to comment.