Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -8,7 +8,9 @@ import { Orientation } from 'vs/base/browser/ui/sash/sash';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { tail2 as tail, equals } from 'vs/base/common/arrays';
import { orthogonal, IView, GridView, Sizing as GridViewSizing, Box, IGridViewStyles } from './gridview';
import { Event } from 'vs/base/common/event';
import { Event, Emitter } from 'vs/base/common/event';
import { $ } from 'vs/base/browser/dom';
import { LayoutPriority } from 'vs/base/browser/ui/splitview/splitview';
export { Orientation } from './gridview';
@@ -186,6 +188,7 @@ export interface IGridStyles extends IGridViewStyles { }
export interface IGridOptions {
styles?: IGridStyles;
proportionalLayout?: boolean;
}
export class Grid<T extends IView> implements IDisposable {
@@ -646,3 +649,63 @@ export function createSerializedGrid(gridDescriptor: GridDescriptor): ISerialize
height: height || 1
};
}
export class View implements IView {
readonly element = $('.grid-view-view');
private visible = false;
private width: number | undefined;
private height: number | undefined;
private orientation: Orientation = Orientation.HORIZONTAL;
get minimumWidth(): number { return this.visible ? this.view.minimumWidth : 0; }
get maximumWidth(): number { return this.visible ? this.view.maximumWidth : (this.orientation === Orientation.HORIZONTAL ? 0 : Number.POSITIVE_INFINITY); }
get minimumHeight(): number { return this.visible ? this.view.minimumHeight : 0; }
get maximumHeight(): number { return this.visible ? this.view.maximumHeight : (this.orientation === Orientation.VERTICAL ? 0 : Number.POSITIVE_INFINITY); }
private onDidChangeVisibility = new Emitter<{ width: number; height: number; } | undefined>();
readonly onDidChange: Event<{ width: number; height: number; } | undefined>;
get priority(): LayoutPriority | undefined { return this.view.priority; }
get snapSize(): number | undefined { return this.visible ? this.view.snapSize : undefined; }
constructor(private view: IView) {
this.show();
this.onDidChange = Event.any(this.onDidChangeVisibility.event, Event.filter(view.onDidChange, () => this.visible));
}
show(): void {
if (this.visible) {
return;
}
this.visible = true;
this.element.appendChild(this.view.element);
this.onDidChangeVisibility.fire(typeof this.width === 'number' ? { width: this.width, height: this.height! } : undefined);
}
hide(): void {
if (!this.visible) {
return;
}
this.visible = false;
this.element.removeChild(this.view.element);
this.onDidChangeVisibility.fire(undefined);
}
layout(width: number, height: number, orientation: Orientation): void {
this.orientation = orientation;
if (!this.visible) {
return;
}
this.view.layout(width, height, orientation);
this.width = width;
this.height = height;
}
}

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./gridview';
import { Event, anyEvent, Emitter, mapEvent, Relay } from 'vs/base/common/event';
import { Event, Emitter, Relay } from 'vs/base/common/event';
import { Orientation, Sash } from 'vs/base/browser/ui/sash/sash';
import { SplitView, IView as ISplitView, Sizing, LayoutPriority, ISplitViewStyles } from 'vs/base/browser/ui/splitview/splitview';
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
@@ -21,10 +21,10 @@ export interface IView {
readonly maximumWidth: number;
readonly minimumHeight: number;
readonly maximumHeight: number;
readonly onDidChange: Event<{ width: number; height: number; }>;
readonly onDidChange: Event<{ width: number; height: number; } | undefined>;
readonly priority?: LayoutPriority;
readonly snapSize?: number;
layout(width: number, height: number): void;
layout(width: number, height: number, orientation: Orientation): void;
}
export function orthogonal(orientation: Orientation): Orientation {
@@ -147,10 +147,10 @@ class BranchNode implements ISplitView, IDisposable {
this._orthogonalSize = orthogonalSize;
this.element = $('.monaco-grid-branch-node');
this.splitview = new SplitView(this.element, { orientation, styles });
this.splitview = new SplitView(this.element, { orientation, styles, proportionalLayout });
this.splitview.layout(size);
const onDidSashReset = mapEvent(this.splitview.onDidSashReset, i => [i]);
const onDidSashReset = Event.map(this.splitview.onDidSashReset, i => [i]);
this.splitviewSashResetDisposable = onDidSashReset(this._onDidSashReset.fire, this._onDidSashReset);
}
@@ -300,15 +300,15 @@ class BranchNode implements ISplitView, IDisposable {
}
private onDidChildrenChange(): void {
const onDidChildrenChange = anyEvent(...this.children.map(c => c.onDidChange));
const onDidChildrenChange = Event.map(Event.any(...this.children.map(c => c.onDidChange)), () => undefined);
this.childrenChangeDisposable.dispose();
this.childrenChangeDisposable = onDidChildrenChange(this._onDidChange.fire, this._onDidChange);
const onDidChildrenSashReset = anyEvent(...this.children.map((c, i) => mapEvent(c.onDidSashReset, location => [i, ...location])));
const onDidChildrenSashReset = Event.any(...this.children.map((c, i) => Event.map(c.onDidSashReset, location => [i, ...location])));
this.childrenSashResetDisposable.dispose();
this.childrenSashResetDisposable = onDidChildrenSashReset(this._onDidSashReset.fire, this._onDidSashReset);
this._onDidChange.fire();
this._onDidChange.fire(undefined);
}
trySet2x2(other: BranchNode): IDisposable {
@@ -348,8 +348,8 @@ class BranchNode implements ISplitView, IDisposable {
mySash.linkedSash = otherSash;
otherSash.linkedSash = mySash;
this._onDidChange.fire();
other._onDidChange.fire();
this._onDidChange.fire(undefined);
other._onDidChange.fire(undefined);
return toDisposable(() => {
mySash.linkedSash = otherSash.linkedSash = undefined;
@@ -391,7 +391,7 @@ class LeafNode implements ISplitView, IDisposable {
set linkedWidthNode(node: LeafNode | undefined) {
this._onDidLinkedWidthNodeChange.input = node ? node._onDidViewChange : Event.None;
this._linkedWidthNode = node;
this._onDidSetLinkedNode.fire();
this._onDidSetLinkedNode.fire(undefined);
}
private _onDidLinkedHeightNodeChange = new Relay<number | undefined>();
@@ -400,7 +400,7 @@ class LeafNode implements ISplitView, IDisposable {
set linkedHeightNode(node: LeafNode | undefined) {
this._onDidLinkedHeightNodeChange.input = node ? node._onDidViewChange : Event.None;
this._linkedHeightNode = node;
this._onDidSetLinkedNode.fire();
this._onDidSetLinkedNode.fire(undefined);
}
private _onDidSetLinkedNode = new Emitter<number | undefined>();
@@ -414,8 +414,8 @@ class LeafNode implements ISplitView, IDisposable {
) {
this._orthogonalSize = orthogonalSize;
this._onDidViewChange = mapEvent(this.view.onDidChange, this.orientation === Orientation.HORIZONTAL ? e => e && e.width : e => e && e.height);
this.onDidChange = anyEvent(this._onDidViewChange, this._onDidSetLinkedNode.event, this._onDidLinkedWidthNodeChange.event, this._onDidLinkedHeightNodeChange.event);
this._onDidViewChange = Event.map(this.view.onDidChange, e => e && (this.orientation === Orientation.VERTICAL ? e.width : e.height));
this.onDidChange = Event.any(this._onDidViewChange, this._onDidSetLinkedNode.event, this._onDidLinkedWidthNodeChange.event, this._onDidLinkedHeightNodeChange.event);
}
get width(): number {
@@ -480,12 +480,12 @@ class LeafNode implements ISplitView, IDisposable {
layout(size: number): void {
this._size = size;
return this.view.layout(this.width, this.height);
return this.view.layout(this.width, this.height, orthogonal(this.orientation));
}
orthogonalLayout(size: number): void {
this._orthogonalSize = size;
return this.view.layout(this.width, this.height);
return this.view.layout(this.width, this.height, orthogonal(this.orientation));
}
dispose(): void { }
@@ -547,7 +547,7 @@ export class GridView implements IDisposable {
this._root = root;
this.element.appendChild(root.element);
this.onDidSashResetRelay.input = root.onDidSashReset;
this._onDidChange.input = mapEvent(root.onDidChange, () => undefined); // TODO
this._onDidChange.input = Event.map(root.onDidChange, () => undefined); // TODO
}
get orientation(): Orientation {
@@ -802,8 +802,7 @@ export class GridView implements IDisposable {
const children: GridNode[] = [];
let offset = 0;
for (let i = 0; i < node.children.length; i++) {
const child = node.children[i];
for (const child of node.children) {
const childOrientation = orthogonal(orientation);
const childBox: Box = orientation === Orientation.HORIZONTAL
? { top: box.top, left: box.left + offset, width: child.width, height: box.height }