Merge VS Code 1.23.1 (#1520)

This commit is contained in:
Matt Irvine
2018-06-05 11:24:51 -07:00
committed by GitHub
parent e3baf5c443
commit 0c58f09e59
3651 changed files with 74249 additions and 48599 deletions

View File

@@ -14,8 +14,8 @@ import product from 'vs/platform/node/product';
import { IWindowsService, OpenContext, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult } from 'vs/platform/windows/common/windows';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { shell, crashReporter, app, Menu, clipboard } from 'electron';
import Event, { chain, fromNodeEventEmitter } from 'vs/base/common/event';
import { IURLService } from 'vs/platform/url/common/url';
import { Event, fromNodeEventEmitter, mapEvent, filterEvent, anyEvent } from 'vs/base/common/event';
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import { IWindowsMainService, ISharedProcess } from 'vs/platform/windows/electron-main/windows';
import { IHistoryMainService, IRecentlyOpened } from 'vs/platform/history/common/history';
@@ -24,17 +24,21 @@ import { ICommandAction } from 'vs/platform/actions/common/actions';
import { Schemas } from 'vs/base/common/network';
import { mnemonicButtonLabel } from 'vs/base/common/labels';
import { isWindows } from 'vs/base/common/platform';
import { ILogService } from '../../log/common/log';
import { ILogService } from 'vs/platform/log/common/log';
export class WindowsService implements IWindowsService, IDisposable {
export class WindowsService implements IWindowsService, IURLHandler, IDisposable {
_serviceBrand: any;
private disposables: IDisposable[] = [];
readonly onWindowOpen: Event<number> = fromNodeEventEmitter(app, 'browser-window-created', (_, w: Electron.BrowserWindow) => w.id);
readonly onWindowFocus: Event<number> = fromNodeEventEmitter(app, 'browser-window-focus', (_, w: Electron.BrowserWindow) => w.id);
readonly onWindowBlur: Event<number> = fromNodeEventEmitter(app, 'browser-window-blur', (_, w: Electron.BrowserWindow) => w.id);
readonly onWindowOpen: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-created', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
readonly onWindowFocus: Event<number> = anyEvent(
mapEvent(filterEvent(mapEvent(this.windowsMainService.onWindowsCountChanged, () => this.windowsMainService.getLastActiveWindow()), w => !!w), w => w.id),
filterEvent(fromNodeEventEmitter(app, 'browser-window-focus', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id))
);
readonly onWindowBlur: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-blur', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
constructor(
private sharedProcess: ISharedProcess,
@@ -45,17 +49,7 @@ export class WindowsService implements IWindowsService, IDisposable {
@IHistoryMainService private historyService: IHistoryMainService,
@ILogService private logService: ILogService
) {
// Catch file URLs
chain(urlService.onOpenURL)
.filter(uri => uri.authority === Schemas.file && !!uri.path)
.map(uri => URI.file(uri.fsPath))
.on(this.openFileForURI, this, this.disposables);
// Catch extension URLs when there are no windows open
chain(urlService.onOpenURL)
.filter(uri => /^extension/.test(uri.path))
.filter(() => this.windowsMainService.getWindowCount() === 0)
.on(this.openExtensionForURI, this, this.disposables);
urlService.registerHandler(this);
}
pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
@@ -496,27 +490,21 @@ export class WindowsService implements IWindowsService, IDisposable {
return TPromise.as(null);
}
private openFileForURI(uri: URI): TPromise<void> {
async handleURL(uri: URI): TPromise<boolean> {
// Catch file URLs
if (uri.authority === Schemas.file && !!uri.path) {
return this.openFileForURI(URI.file(uri.fsPath));
}
return false;
}
private async openFileForURI(uri: URI): TPromise<boolean> {
const cli = assign(Object.create(null), this.environmentService.args, { goto: true });
const pathsToOpen = [uri.fsPath];
this.windowsMainService.open({ context: OpenContext.API, cli, pathsToOpen });
return TPromise.as(null);
}
/**
* This should only fire whenever an extension URL is open
* and there are no windows to handle it.
*/
private async openExtensionForURI(uri: URI): TPromise<void> {
const cli = assign(Object.create(null), this.environmentService.args);
const window = await this.windowsMainService.open({ context: OpenContext.API, cli })[0];
if (!window) {
return;
}
window.win.show();
return true;
}
dispose(): void {