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

@@ -7,7 +7,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import Event from 'vs/base/common/event';
import { Event, latch, anyEvent } from 'vs/base/common/event';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
@@ -16,6 +16,7 @@ import { IRecentlyOpened } from 'vs/platform/history/common/history';
import { ICommandAction } from 'vs/platform/actions/common/actions';
import { PerformanceEntry } from 'vs/base/common/performance';
import { LogLevel } from 'vs/platform/log/common/log';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
export const IWindowsService = createDecorator<IWindowsService>('windowsService');
@@ -213,6 +214,7 @@ export interface IWindowsConfiguration {
export interface IWindowSettings {
openFilesInNewWindow: 'on' | 'off' | 'default';
openFoldersInNewWindow: 'on' | 'off' | 'default';
openWithoutArgumentsInNewWindow: 'on' | 'off';
restoreWindows: 'all' | 'folders' | 'one' | 'none';
restoreFullscreen: boolean;
zoomLevel: number;
@@ -223,6 +225,8 @@ export interface IWindowSettings {
nativeTabs: boolean;
enableMenuBarMnemonics: boolean;
closeWhenEmpty: boolean;
smoothScrollingWorkaround: boolean;
clickThroughInactive: boolean;
}
export enum OpenContext {
@@ -291,6 +295,7 @@ export interface IOpenFileRequest {
filesToCreate?: IPath[];
filesToDiff?: IPath[];
filesToWait?: IPathsToWaitFor;
termProgram?: string;
}
export interface IAddFoldersRequest {
@@ -331,3 +336,26 @@ export interface IRunActionInWindowRequest {
id: string;
from: 'menu' | 'touchbar' | 'mouse';
}
export class ActiveWindowManager implements IDisposable {
private disposables: IDisposable[] = [];
private _activeWindowId: number;
constructor(@IWindowsService windowsService: IWindowsService) {
const onActiveWindowChange = latch(anyEvent(windowsService.onWindowOpen, windowsService.onWindowFocus));
onActiveWindowChange(this.setActiveWindow, this, this.disposables);
}
private setActiveWindow(windowId: number) {
this._activeWindowId = windowId;
}
get activeClientId(): string {
return `window:${this._activeWindowId}`;
}
dispose() {
this.disposables = dispose(this.disposables);
}
}

View File

@@ -6,7 +6,7 @@
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import Event, { buffer } from 'vs/base/common/event';
import { Event, buffer } from 'vs/base/common/event';
import { IChannel, eventToCall, eventFromCall } from 'vs/base/parts/ipc/common/ipc';
import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, CrashReporterStartOptions, IMessageBoxResult, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions } from 'vs/platform/windows/common/windows';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';

View File

@@ -5,7 +5,7 @@
'use strict';
import Event, { filterEvent, mapEvent, anyEvent } from 'vs/base/common/event';
import { Event, filterEvent, mapEvent, anyEvent } from 'vs/base/common/event';
import { TPromise } from 'vs/base/common/winjs.base';
import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { IRecentlyOpened } from 'vs/platform/history/common/history';

View File

@@ -8,12 +8,28 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { OpenContext, IWindowConfiguration, ReadyState, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult } from 'vs/platform/windows/common/windows';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import Event from 'vs/base/common/event';
import { Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
import { ICommandAction } from 'vs/platform/actions/common/actions';
export interface IWindowState {
width?: number;
height?: number;
x?: number;
y?: number;
mode?: WindowMode;
display?: number;
}
export enum WindowMode {
Maximized,
Normal,
Minimized, // not used anymore, but also cannot remove due to existing stored UI state (needs migration)
Fullscreen
}
export interface ICodeWindow {
id: number;
win: Electron.BrowserWindow;
@@ -21,13 +37,24 @@ export interface ICodeWindow {
openedFolderPath: string;
openedWorkspace: IWorkspaceIdentifier;
backupPath: string;
isExtensionDevelopmentHost: boolean;
isExtensionTestHost: boolean;
lastFocusTime: number;
readyState: ReadyState;
ready(): TPromise<ICodeWindow>;
load(config: IWindowConfiguration, isReload?: boolean): void;
reload(configuration?: IWindowConfiguration, cli?: ParsedArgs): void;
focus(): void;
close(): void;
getBounds(): Electron.Rectangle;
send(channel: string, ...args: any[]): void;
sendWhenReady(channel: string, ...args: any[]): void;
@@ -38,6 +65,11 @@ export interface ICodeWindow {
onWindowTitleDoubleClick(): void;
updateTouchBar(items: ICommandAction[][]): void;
setReady(): void;
serializeWindowState(): IWindowState;
dispose(): void;
}
export const IWindowsMainService = createDecorator<IWindowsMainService>('windowsMainService');
@@ -75,7 +107,7 @@ export interface IWindowsMainService {
focusLastActive(cli: ParsedArgs, context: OpenContext): ICodeWindow;
getLastActiveWindow(): ICodeWindow;
waitForWindowCloseOrLoad(windowId: number): TPromise<void>;
openNewWindow(context: OpenContext): void;
openNewWindow(context: OpenContext): ICodeWindow[];
sendToFocused(channel: string, ...args: any[]): void;
sendToAll(channel: string, payload: any, windowIdsToIgnore?: number[]): void;
getFocusedWindow(): ICodeWindow;

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 {