mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from master
This commit is contained in:
@@ -3,19 +3,15 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { WORKSPACE_EXTENSION, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { extname, basename, normalize } from 'vs/base/common/paths';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import URI from 'vs/base/common/uri';
|
||||
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';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEditorViewState } from 'vs/editor/common/editorCommon';
|
||||
@@ -35,7 +31,6 @@ import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/co
|
||||
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 { IUriDisplayService } from 'vs/platform/uriDisplay/common/uriDisplay';
|
||||
|
||||
export interface IDraggedResource {
|
||||
resource: URI;
|
||||
@@ -166,8 +161,7 @@ export class ResourcesDropHandler {
|
||||
@IBackupFileService private backupFileService: IBackupFileService,
|
||||
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
|
||||
@IEditorService private editorService: IEditorService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IUriDisplayService private uriDisplayService: IUriDisplayService
|
||||
@IConfigurationService private configurationService: IConfigurationService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -178,7 +172,7 @@ export class ResourcesDropHandler {
|
||||
}
|
||||
|
||||
// Make the window active to handle the drop properly within
|
||||
return this.windowService.focusWindow().then(() => {
|
||||
this.windowService.focusWindow().then(() => {
|
||||
|
||||
// Check for special things being dropped
|
||||
return this.doHandleDrop(untitledOrFileResources).then(isWorkspaceOpening => {
|
||||
@@ -189,7 +183,7 @@ 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.map(resource => this.uriDisplayService.getLabel(resource)));
|
||||
this.windowsService.addRecentlyOpened(filesToAddToHistory);
|
||||
}
|
||||
|
||||
const editors: IResourceEditor[] = untitledOrFileResources.map(untitledOrFileResource => ({
|
||||
@@ -209,15 +203,15 @@ export class ResourcesDropHandler {
|
||||
afterDrop(targetGroup);
|
||||
});
|
||||
});
|
||||
}).done(null, onUnexpectedError);
|
||||
});
|
||||
}
|
||||
|
||||
private doHandleDrop(untitledOrFileResources: (IDraggedResource | IDraggedEditor)[]): TPromise<boolean> {
|
||||
private doHandleDrop(untitledOrFileResources: (IDraggedResource | IDraggedEditor)[]): Thenable<boolean> {
|
||||
|
||||
// Check for dirty editors being dropped
|
||||
const resourcesWithBackups: IDraggedEditor[] = untitledOrFileResources.filter(resource => !resource.isExternal && !!(resource as IDraggedEditor).backupResource);
|
||||
if (resourcesWithBackups.length > 0) {
|
||||
return TPromise.join(resourcesWithBackups.map(resourceWithBackup => this.handleDirtyEditorDrop(resourceWithBackup))).then(() => false);
|
||||
return Promise.all(resourcesWithBackups.map(resourceWithBackup => this.handleDirtyEditorDrop(resourceWithBackup))).then(() => false);
|
||||
}
|
||||
|
||||
// Check for workspace file being dropped if we are allowed to do so
|
||||
@@ -228,10 +222,10 @@ export class ResourcesDropHandler {
|
||||
}
|
||||
}
|
||||
|
||||
return TPromise.as(false);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
private handleDirtyEditorDrop(droppedDirtyEditor: IDraggedEditor): TPromise<boolean> {
|
||||
private handleDirtyEditorDrop(droppedDirtyEditor: IDraggedEditor): Thenable<boolean> {
|
||||
|
||||
// Untitled: always ensure that we open a new untitled for each file we drop
|
||||
if (droppedDirtyEditor.resource.scheme === Schemas.untitled) {
|
||||
@@ -240,7 +234,7 @@ export class ResourcesDropHandler {
|
||||
|
||||
// Return early if the resource is already dirty in target or opened already
|
||||
if (this.textFileService.isDirty(droppedDirtyEditor.resource) || this.editorService.isOpen({ resource: droppedDirtyEditor.resource })) {
|
||||
return TPromise.as(false);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
// Resolve the contents of the dropped dirty resource from source
|
||||
@@ -260,13 +254,13 @@ export class ResourcesDropHandler {
|
||||
return DefaultEndOfLine.LF;
|
||||
}
|
||||
|
||||
private handleWorkspaceFileDrop(fileOnDiskResources: URI[]): TPromise<boolean> {
|
||||
private handleWorkspaceFileDrop(fileOnDiskResources: URI[]): Thenable<boolean> {
|
||||
const workspaceResources: { workspaces: URI[], folders: URI[] } = {
|
||||
workspaces: [],
|
||||
folders: []
|
||||
};
|
||||
|
||||
return TPromise.join(fileOnDiskResources.map(fileOnDiskResource => {
|
||||
return Promise.all(fileOnDiskResources.map(fileOnDiskResource => {
|
||||
|
||||
// Check for Workspace
|
||||
if (extname(fileOnDiskResource.fsPath) === `.${WORKSPACE_EXTENSION}`) {
|
||||
@@ -292,11 +286,11 @@ export class ResourcesDropHandler {
|
||||
// Pass focus to window
|
||||
this.windowService.focusWindow();
|
||||
|
||||
let workspacesToOpen: TPromise<URI[]>;
|
||||
let workspacesToOpen: Thenable<URI[]>;
|
||||
|
||||
// Open in separate windows if we drop workspaces or just one folder
|
||||
if (workspaces.length > 0 || folders.length === 1) {
|
||||
workspacesToOpen = TPromise.as([...workspaces, ...folders].map(resources => resources));
|
||||
workspacesToOpen = Promise.resolve([...workspaces, ...folders].map(resources => resources));
|
||||
}
|
||||
|
||||
// Multiple folders: Create new workspace with folders and open
|
||||
|
||||
Reference in New Issue
Block a user