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

@@ -5,7 +5,7 @@
'use strict';
import Event, { anyEvent } from 'vs/base/common/event';
import { Event, anyEvent } from 'vs/base/common/event';
import { Orientation } from 'vs/base/browser/ui/sash/sash';
import { append, $ } from 'vs/base/browser/dom';
import { SplitView, IView } from 'vs/base/browser/ui/splitview/splitview';

View File

@@ -7,7 +7,7 @@
import 'vs/css!./panelview';
import { IDisposable, dispose, combinedDisposable } from 'vs/base/common/lifecycle';
import Event, { Emitter, chain } from 'vs/base/common/event';
import { Event, Emitter, chain } from 'vs/base/common/event';
import { domEvent } from 'vs/base/browser/event';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
@@ -239,7 +239,7 @@ class PanelDraggable implements IDisposable {
private _onDidDrop = new Emitter<{ from: Panel, to: Panel }>();
readonly onDidDrop = this._onDidDrop.event;
constructor(private panel: Panel, private context: IDndContext) {
constructor(private panel: Panel, private dnd: IPanelDndController, private context: IDndContext) {
panel.draggableElement.draggable = true;
domEvent(panel.draggableElement, 'dragstart')(this.onDragStart, this, this.disposables);
domEvent(panel.dropTargetElement, 'dragenter')(this.onDragEnter, this, this.disposables);
@@ -249,6 +249,12 @@ class PanelDraggable implements IDisposable {
}
private onDragStart(e: DragEvent): void {
if (!this.dnd.canDrag(this.panel)) {
e.preventDefault();
e.stopPropagation();
return;
}
e.dataTransfer.effectAllowed = 'move';
const dragImage = append(document.body, $('.monaco-panel-drag-image', {}, this.panel.draggableElement.textContent));
@@ -263,6 +269,10 @@ class PanelDraggable implements IDisposable {
return;
}
if (!this.dnd.canDrop(this.context.draggable.panel, this.panel)) {
return;
}
this.dragOverCounter++;
this.render();
}
@@ -272,6 +282,10 @@ class PanelDraggable implements IDisposable {
return;
}
if (!this.dnd.canDrop(this.context.draggable.panel, this.panel)) {
return;
}
this.dragOverCounter--;
if (this.dragOverCounter === 0) {
@@ -297,7 +311,7 @@ class PanelDraggable implements IDisposable {
this.dragOverCounter = 0;
this.render();
if (this.context.draggable !== this) {
if (this.dnd.canDrop(this.context.draggable.panel, this.panel) && this.context.draggable !== this) {
this._onDidDrop.fire({ from: this.context.draggable.panel, to: this.panel });
}
@@ -319,8 +333,24 @@ class PanelDraggable implements IDisposable {
}
}
export class IPanelViewOptions {
dnd?: boolean;
export interface IPanelDndController {
canDrag(panel: Panel): boolean;
canDrop(panel: Panel, overPanel: Panel): boolean;
}
export class DefaultPanelDndController implements IPanelDndController {
canDrag(panel: Panel): boolean {
return true;
}
canDrop(panel: Panel, overPanel: Panel): boolean {
return true;
}
}
export interface IPanelViewOptions {
dnd?: IPanelDndController;
}
interface IPanelItem {
@@ -330,7 +360,7 @@ interface IPanelItem {
export class PanelView implements IDisposable {
private dnd: boolean;
private dnd: IPanelDndController | null;
private dndContext: IDndContext = { draggable: null };
private el: HTMLElement;
private panelItems: IPanelItem[] = [];
@@ -343,7 +373,7 @@ export class PanelView implements IDisposable {
readonly onDidSashChange: Event<void>;
constructor(container: HTMLElement, options: IPanelViewOptions = {}) {
this.dnd = !!options.dnd;
this.dnd = options.dnd;
this.el = append(container, $('.monaco-panel-view'));
this.splitview = new SplitView(this.el);
this.onDidSashChange = this.splitview.onDidSashChange;
@@ -358,7 +388,7 @@ export class PanelView implements IDisposable {
this.splitview.addView(panel, size, index);
if (this.dnd) {
const draggable = new PanelDraggable(panel, this.dndContext);
const draggable = new PanelDraggable(panel, this.dnd, this.dndContext);
disposables.push(draggable);
draggable.onDidDrop(this._onDidDrop.fire, this._onDidDrop, disposables);
}

View File

@@ -10,15 +10,20 @@
height: 100%;
}
.monaco-split-view2 > .split-view-view {
.monaco-split-view2 > .split-view-container {
width: 100%;
height: 100%;
}
.monaco-split-view2 > .split-view-container > .split-view-view {
overflow: hidden;
}
.monaco-split-view2.vertical > .split-view-view {
.monaco-split-view2.vertical > .split-view-container > .split-view-view {
width: 100%;
}
.monaco-split-view2.horizontal > .split-view-view {
.monaco-split-view2.horizontal > .split-view-container > .split-view-view {
height: 100%;
display: inline-block;
}

View File

@@ -7,9 +7,9 @@
import 'vs/css!./splitview';
import { IDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
import Event, { mapEvent, Emitter } from 'vs/base/common/event';
import types = require('vs/base/common/types');
import dom = require('vs/base/browser/dom');
import { Event, mapEvent, Emitter } from 'vs/base/common/event';
import * as types from 'vs/base/common/types';
import * as dom from 'vs/base/browser/dom';
import { clamp } from 'vs/base/common/numbers';
import { range, firstIndex } from 'vs/base/common/arrays';
import { Sash, Orientation, ISashEvent as IBaseSashEvent } from 'vs/base/browser/ui/sash/sash';
@@ -82,6 +82,7 @@ export class SplitView implements IDisposable {
private orientation: Orientation;
private el: HTMLElement;
private viewContainer: HTMLElement;
private size = 0;
private contentSize = 0;
private viewItems: IViewItem[] = [];
@@ -105,6 +106,10 @@ export class SplitView implements IDisposable {
dom.addClass(this.el, 'monaco-split-view2');
dom.addClass(this.el, this.orientation === Orientation.VERTICAL ? 'vertical' : 'horizontal');
container.appendChild(this.el);
this.viewContainer = document.createElement('div');
dom.addClass(this.viewContainer, 'split-view-container');
this.el.appendChild(this.viewContainer);
}
addView(view: IView, size: number, index = this.viewItems.length): void {
@@ -118,13 +123,13 @@ export class SplitView implements IDisposable {
const container = dom.$('.split-view-view');
if (index === this.viewItems.length) {
this.el.appendChild(container);
this.viewContainer.appendChild(container);
} else {
this.el.insertBefore(container, this.el.children.item(index));
this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
}
const onChangeDisposable = view.onDidChange(size => this.onViewChange(item, size));
const containerDisposable = toDisposable(() => this.el.removeChild(container));
const containerDisposable = toDisposable(() => this.viewContainer.removeChild(container));
const disposable = combinedDisposable([onChangeDisposable, containerDisposable]);
const layoutContainer = this.orientation === Orientation.VERTICAL
@@ -218,9 +223,9 @@ export class SplitView implements IDisposable {
this.viewItems.splice(to, 0, viewItem);
if (to + 1 < this.viewItems.length) {
this.el.insertBefore(viewItem.container, this.viewItems[to + 1].container);
this.viewContainer.insertBefore(viewItem.container, this.viewItems[to + 1].container);
} else {
this.el.appendChild(viewItem.container);
this.viewContainer.appendChild(viewItem.container);
}
this.layoutViews();