Vscode merge (#4582)

* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd

* fix issues with merges

* bump node version in azpipe

* replace license headers

* remove duplicate launch task

* fix build errors

* fix build errors

* fix tslint issues

* working through package and linux build issues

* more work

* wip

* fix packaged builds

* working through linux build errors

* wip

* wip

* wip

* fix mac and linux file limits

* iterate linux pipeline

* disable editor typing

* revert series to parallel

* remove optimize vscode from linux

* fix linting issues

* revert testing change

* add work round for new node

* readd packaging for extensions

* fix issue with angular not resolving decorator dependencies
This commit is contained in:
Anthony Dresser
2019-03-19 17:44:35 -07:00
committed by GitHub
parent 833d197412
commit 87765e8673
1879 changed files with 54505 additions and 38058 deletions

View File

@@ -3,10 +3,11 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { WORKSPACE_EXTENSION, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { extname, basename, normalize } from 'vs/base/common/paths';
import { hasWorkspaceFileExtension, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { normalize } from 'vs/base/common/path';
import { basename } from 'vs/base/common/resources';
import { IFileService } from 'vs/platform/files/common/files';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { IWindowsService, IWindowService, IURIToOpen } from 'vs/platform/windows/common/windows';
import { URI } from 'vs/base/common/uri';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
@@ -15,22 +16,19 @@ import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/un
import { DefaultEndOfLine } from 'vs/editor/common/model';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEditorViewState } from 'vs/editor/common/editorCommon';
import { DataTransfers, IDragAndDropData } from 'vs/base/browser/dnd';
import { DefaultDragAndDrop } from 'vs/base/parts/tree/browser/treeDefaults';
import { DataTransfers } from 'vs/base/browser/dnd';
import { DragMouseEvent } from 'vs/base/browser/mouseEvent';
import { normalizeDriveLetter } from 'vs/base/common/labels';
import { MIME_BINARY } from 'vs/base/common/mime';
import { ITree } from 'vs/base/parts/tree/browser/tree';
import { isWindows } from 'vs/base/common/platform';
import { coalesce } from 'vs/base/common/arrays';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { IEditorIdentifier, GroupIdentifier } from 'vs/workbench/common/editor';
import { basenameOrAuthority } from 'vs/base/common/resources';
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
import { Disposable } from 'vs/base/common/lifecycle';
import { addDisposableListener, EventType } from 'vs/base/browser/dom';
import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsService';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IRecentFile } from 'vs/platform/history/common/history';
export interface IDraggedResource {
resource: URI;
@@ -60,8 +58,8 @@ export interface IDraggedEditor extends IDraggedResource {
export interface ISerializedDraggedEditor {
resource: string;
backupResource: string;
viewState: IEditorViewState;
backupResource?: string;
viewState: IEditorViewState | null;
}
export const CodeDataTransfers = {
@@ -71,7 +69,7 @@ export const CodeDataTransfers = {
export function extractResources(e: DragEvent, externalOnly?: boolean): Array<IDraggedResource | IDraggedEditor> {
const resources: Array<IDraggedResource | IDraggedEditor> = [];
if (e.dataTransfer.types.length > 0) {
if (e.dataTransfer && e.dataTransfer.types.length > 0) {
// Check for window-to-window DND
if (!externalOnly) {
@@ -165,7 +163,7 @@ export class ResourcesDropHandler {
) {
}
handleDrop(event: DragEvent, resolveTargetGroup: () => IEditorGroup, afterDrop: (targetGroup: IEditorGroup) => void, targetIndex?: number): void {
handleDrop(event: DragEvent, resolveTargetGroup: () => IEditorGroup | undefined, afterDrop: (targetGroup: IEditorGroup | undefined) => void, targetIndex?: number): void {
const untitledOrFileResources = extractResources(event).filter(r => this.fileService.canHandleResource(r.resource) || r.resource.scheme === Schemas.untitled);
if (!untitledOrFileResources.length) {
return;
@@ -181,9 +179,9 @@ export class ResourcesDropHandler {
}
// Add external ones to recently open list unless dropped resource is a workspace
const filesToAddToHistory = untitledOrFileResources.filter(d => d.isExternal && d.resource.scheme === Schemas.file).map(d => d.resource);
if (filesToAddToHistory.length) {
this.windowsService.addRecentlyOpened(filesToAddToHistory);
const recents: IRecentFile[] = untitledOrFileResources.filter(d => d.isExternal && d.resource.scheme === Schemas.file).map(d => ({ fileUri: d.resource }));
if (recents.length) {
this.windowsService.addRecentlyOpened(recents);
}
const editors: IResourceEditor[] = untitledOrFileResources.map(untitledOrFileResource => ({
@@ -238,10 +236,10 @@ export class ResourcesDropHandler {
}
// Resolve the contents of the dropped dirty resource from source
return this.backupFileService.resolveBackupContent(droppedDirtyEditor.backupResource).then(content => {
return this.backupFileService.resolveBackupContent(droppedDirtyEditor.backupResource!).then(content => {
// Set the contents of to the resource to the target
return this.backupFileService.backupResource(droppedDirtyEditor.resource, content.create(this.getDefaultEOL()).createSnapshot(true));
return this.backupFileService.backupResource(droppedDirtyEditor.resource, content!.create(this.getDefaultEOL()).createSnapshot(true));
}).then(() => false, () => false /* ignore any error */);
}
@@ -255,7 +253,7 @@ export class ResourcesDropHandler {
}
private handleWorkspaceFileDrop(fileOnDiskResources: URI[]): Promise<boolean> {
const workspaceResources: { workspaces: URI[], folders: URI[] } = {
const workspaceResources: { workspaces: IURIToOpen[], folders: IURIToOpen[] } = {
workspaces: [],
folders: []
};
@@ -263,8 +261,8 @@ export class ResourcesDropHandler {
return Promise.all(fileOnDiskResources.map(fileOnDiskResource => {
// Check for Workspace
if (extname(fileOnDiskResource.fsPath) === `.${WORKSPACE_EXTENSION}`) {
workspaceResources.workspaces.push(fileOnDiskResource);
if (hasWorkspaceFileExtension(fileOnDiskResource.fsPath)) {
workspaceResources.workspaces.push({ uri: fileOnDiskResource, typeHint: 'file' });
return undefined;
}
@@ -272,7 +270,7 @@ export class ResourcesDropHandler {
// Check for Folder
return this.fileService.resolveFile(fileOnDiskResource).then(stat => {
if (stat.isDirectory) {
workspaceResources.folders.push(stat.resource);
workspaceResources.folders.push({ uri: stat.resource, typeHint: 'folder' });
}
}, error => undefined);
})).then(_ => {
@@ -286,71 +284,32 @@ export class ResourcesDropHandler {
// Pass focus to window
this.windowService.focusWindow();
let workspacesToOpen: Promise<URI[]>;
let workspacesToOpen: Promise<IURIToOpen[]> | undefined;
// Open in separate windows if we drop workspaces or just one folder
if (workspaces.length > 0 || folders.length === 1) {
workspacesToOpen = Promise.resolve([...workspaces, ...folders].map(resources => resources));
workspacesToOpen = Promise.resolve([...workspaces, ...folders]);
}
// Multiple folders: Create new workspace with folders and open
else if (folders.length > 1) {
workspacesToOpen = this.workspacesService.createUntitledWorkspace(folders.map(folder => ({ uri: folder }))).then(workspace => [URI.file(workspace.configPath)]);
workspacesToOpen = this.workspacesService.createUntitledWorkspace(folders).then(workspace => [<IURIToOpen>{ uri: workspace.configPath, typeHint: 'file' }]);
}
// Open
workspacesToOpen.then(workspaces => {
this.windowService.openWindow(workspaces, { forceReuseWindow: true });
});
if (workspacesToOpen) {
workspacesToOpen.then(workspaces => {
this.windowService.openWindow(workspaces, { forceReuseWindow: true });
});
}
return true;
});
}
}
export class SimpleFileResourceDragAndDrop extends DefaultDragAndDrop {
constructor(
private toResource: (obj: any) => URI,
@IInstantiationService protected instantiationService: IInstantiationService
) {
super();
}
getDragURI(tree: ITree, obj: any): string {
const resource = this.toResource(obj);
if (resource) {
return resource.toString();
}
return undefined;
}
getDragLabel(tree: ITree, elements: any[]): string {
if (elements.length > 1) {
return String(elements.length);
}
const resource = this.toResource(elements[0]);
if (resource) {
return basenameOrAuthority(resource);
}
return undefined;
}
onDragStart(tree: ITree, data: IDragAndDropData, originalEvent: DragMouseEvent): void {
// Apply some datatransfer types to allow for dragging the element outside of the application
const resources: URI[] = data.getData().map(source => this.toResource(source));
if (resources) {
this.instantiationService.invokeFunction(fillResourceDataTransfers, coalesce(resources), originalEvent);
}
}
}
export function fillResourceDataTransfers(accessor: ServicesAccessor, resources: (URI | { resource: URI, isDirectory: boolean })[], event: DragMouseEvent | DragEvent): void {
if (resources.length === 0) {
if (resources.length === 0 || !event.dataTransfer) {
return;
}
@@ -366,11 +325,11 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources:
// Text: allows to paste into text-capable areas
const lineDelimiter = isWindows ? '\r\n' : '\n';
event.dataTransfer.setData(DataTransfers.TEXT, sources.map(source => source.resource.scheme === Schemas.file ? normalize(normalizeDriveLetter(source.resource.fsPath), true) : source.resource.toString()).join(lineDelimiter));
event.dataTransfer.setData(DataTransfers.TEXT, sources.map(source => source.resource.scheme === Schemas.file ? normalize(normalizeDriveLetter(source.resource.fsPath)) : source.resource.toString()).join(lineDelimiter));
// Download URL: enables support to drag a tab as file to desktop (only single file supported)
if (firstSource.resource.scheme === Schemas.file) {
event.dataTransfer.setData(DataTransfers.DOWNLOAD_URL, [MIME_BINARY, basename(firstSource.resource.fsPath), firstSource.resource.toString()].join(':'));
event.dataTransfer.setData(DataTransfers.DOWNLOAD_URL, [MIME_BINARY, basename(firstSource.resource), firstSource.resource.toString()].join(':'));
}
// Resource URLs: allows to drop multiple resources to a target in VS Code (not directories)
@@ -388,7 +347,7 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources:
files.forEach(file => {
// Try to find editor view state from the visible editors that match given resource
let viewState: IEditorViewState;
let viewState: IEditorViewState | null = null;
const textEditorWidgets = editorService.visibleTextEditorWidgets;
for (const textEditorWidget of textEditorWidgets) {
if (isCodeEditor(textEditorWidget)) {
@@ -420,8 +379,8 @@ export class LocalSelectionTransfer<T> {
private static readonly INSTANCE = new LocalSelectionTransfer();
private data: T[];
private proto: T;
private data?: T[];
private proto?: T;
private constructor() {
// protect against external instantiation
@@ -442,7 +401,7 @@ export class LocalSelectionTransfer<T> {
}
}
getData(proto: T): T[] {
getData(proto: T): T[] | undefined {
if (this.hasData(proto)) {
return this.data;
}
@@ -489,6 +448,8 @@ export class DragAndDropObserver extends Disposable {
}));
this._register(addDisposableListener(this.element, EventType.DRAG_OVER, (e: DragEvent) => {
e.preventDefault(); // needed so that the drop event fires (https://stackoverflow.com/questions/21339924/drop-event-not-firing-in-chrome)
if (this.callbacks.onDragOver) {
this.callbacks.onDragOver(e);
}