Merge VS Code 1.21 source code (#1067)

* Initial VS Code 1.21 file copy with patches

* A few more merges

* Post npm install

* Fix batch of build breaks

* Fix more build breaks

* Fix more build errors

* Fix more build breaks

* Runtime fixes 1

* Get connection dialog working with some todos

* Fix a few packaging issues

* Copy several node_modules to package build to fix loader issues

* Fix breaks from master

* A few more fixes

* Make tests pass

* First pass of license header updates

* Second pass of license header updates

* Fix restore dialog issues

* Remove add additional themes menu items

* fix select box issues where the list doesn't show up

* formatting

* Fix editor dispose issue

* Copy over node modules to correct location on all platforms
This commit is contained in:
Karl Burtram
2018-04-04 15:27:51 -07:00
committed by GitHub
parent 5fba3e31b4
commit dafb780987
9412 changed files with 141255 additions and 98813 deletions

View File

@@ -38,8 +38,14 @@ export enum ClickBehavior {
ON_MOUSE_UP
}
export enum OpenMode {
SINGLE_CLICK,
DOUBLE_CLICK
}
export interface IControllerOptions {
clickBehavior?: ClickBehavior;
openMode?: OpenMode;
keyboardSupport?: boolean;
}
@@ -82,7 +88,7 @@ export class DefaultController implements _.IController {
private options: IControllerOptions;
constructor(options: IControllerOptions = { clickBehavior: ClickBehavior.ON_MOUSE_UP, keyboardSupport: true }) {
constructor(options: IControllerOptions = { clickBehavior: ClickBehavior.ON_MOUSE_DOWN, keyboardSupport: true, openMode: OpenMode.SINGLE_CLICK }) {
this.options = options;
this.downKeyBindingDispatcher = new KeybindingDispatcher();
@@ -153,12 +159,14 @@ export class DefaultController implements _.IController {
protected onLeftClick(tree: _.ITree, element: any, eventish: ICancelableEvent, origin: string = 'mouse'): boolean {
const payload = { origin: origin, originalEvent: eventish };
const event = <mouse.IMouseEvent>eventish;
const isDoubleClick = (origin === 'mouse' && event.detail === 2);
if (tree.getInput() === element) {
tree.clearFocus(payload);
tree.clearSelection(payload);
} else {
const isMouseDown = eventish && (<mouse.IMouseEvent>eventish).browserEvent && (<mouse.IMouseEvent>eventish).browserEvent.type === 'mousedown';
const isMouseDown = eventish && event.browserEvent && event.browserEvent.type === 'mousedown';
if (!isMouseDown) {
eventish.preventDefault(); // we cannot preventDefault onMouseDown because this would break DND otherwise
}
@@ -168,16 +176,36 @@ export class DefaultController implements _.IController {
tree.setSelection([element], payload);
tree.setFocus(element, payload);
if (tree.isExpanded(element)) {
tree.collapse(element).done(null, errors.onUnexpectedError);
} else {
tree.expand(element).done(null, errors.onUnexpectedError);
if (this.openOnSingleClick || isDoubleClick || this.isClickOnTwistie(event)) {
if (tree.isExpanded(element)) {
tree.collapse(element).done(null, errors.onUnexpectedError);
} else {
tree.expand(element).done(null, errors.onUnexpectedError);
}
}
}
return true;
}
protected setOpenMode(openMode: OpenMode) {
this.options.openMode = openMode;
}
protected get openOnSingleClick(): boolean {
return this.options.openMode === OpenMode.SINGLE_CLICK;
}
protected isClickOnTwistie(event: mouse.IMouseEvent): boolean {
const target = event.target as HTMLElement;
// There is no way to find out if the ::before element is clicked where
// the twistie is drawn, but the <div class="content"> element in the
// tree item is the only thing we get back as target when the user clicks
// on the twistie.
return target && target.className === 'content' && dom.hasClass(target.parentElement, 'monaco-tree-row');
}
public onContextMenu(tree: _.ITree, element: any, event: _.ContextMenuEvent): boolean {
if (event.target && event.target.tagName && event.target.tagName.toLowerCase() === 'input') {
return false; // allow context menu on input fields

View File

@@ -6,10 +6,6 @@
import _ = require('vs/base/parts/tree/browser/tree');
import Mouse = require('vs/base/browser/mouseEvent');
import { DefaultDragAndDrop } from 'vs/base/parts/tree/browser/treeDefaults';
import URI from 'vs/base/common/uri';
import { basename } from 'vs/base/common/paths';
import { getPathLabel } from 'vs/base/common/labels';
export class ElementsDragAndDropData implements _.IDragAndDropData {
@@ -75,48 +71,4 @@ export class DesktopDragAndDropData implements _.IDragAndDropData {
files: this.files
};
}
}
export class SimpleFileResourceDragAndDrop extends DefaultDragAndDrop {
constructor(private toResource: (obj: any) => URI) {
super();
}
public getDragURI(tree: _.ITree, obj: any): string {
const resource = this.toResource(obj);
if (resource) {
return resource.toString();
}
return void 0;
}
public getDragLabel(tree: _.ITree, elements: any[]): string {
if (elements.length > 1) {
return String(elements.length);
}
const resource = this.toResource(elements[0]);
if (resource) {
return basename(resource.fsPath);
}
return void 0;
}
public onDragStart(tree: _.ITree, data: _.IDragAndDropData, originalEvent: Mouse.DragMouseEvent): void {
const sources: object[] = data.getData();
let source: object = null;
if (sources.length > 0) {
source = sources[0];
}
// Apply some datatransfer types to allow for dragging the element outside of the application
const resource = this.toResource(source);
if (resource) {
originalEvent.dataTransfer.setData('text/plain', getPathLabel(resource));
}
}
}

View File

@@ -24,6 +24,7 @@ import _ = require('vs/base/parts/tree/browser/tree');
import { KeyCode } from 'vs/base/common/keyCodes';
import Event, { Emitter } from 'vs/base/common/event';
import { IDomNodePagePosition } from 'vs/base/browser/dom';
import { DataTransfers } from 'vs/base/browser/dnd';
export interface IRow {
element: HTMLElement;
@@ -825,7 +826,7 @@ export class TreeView extends HeightMap {
public getScrollPosition(): number {
const height = this.getTotalHeight() - this.viewHeight;
return height <= 0 ? 0 : this.scrollTop / height;
return height <= 0 ? 1 : this.scrollTop / height;
}
public setScrollPosition(pos: number): void {
@@ -1291,7 +1292,7 @@ export class TreeView extends HeightMap {
}
e.dataTransfer.effectAllowed = 'copyMove';
e.dataTransfer.setData('URL', item.uri);
e.dataTransfer.setData(DataTransfers.RESOURCES, JSON.stringify([item.uri]));
if (e.dataTransfer.setDragImage) {
let label: string;
@@ -1658,4 +1659,4 @@ export class TreeView extends HeightMap {
super.dispose();
}
}
}