mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421 (#7404)
* Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421 * readd svgs
This commit is contained in:
@@ -7,7 +7,8 @@ import { hasWorkspaceFileExtension, IWorkspaceFolderCreationData } from 'vs/plat
|
||||
import { normalize } from 'vs/base/common/path';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IWindowService, IURIToOpen } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowOpenable } from 'vs/platform/windows/common/windows';
|
||||
import { IWorkspacesHistoryService } from 'vs/workbench/services/workspace/common/workspacesHistoryService';
|
||||
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';
|
||||
@@ -28,10 +29,11 @@ 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/editor/common/editorGroupsService';
|
||||
import { IRecentFile } from 'vs/platform/history/common/history';
|
||||
import { IRecentFile } from 'vs/platform/workspaces/common/workspacesHistory';
|
||||
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
|
||||
export interface IDraggedResource {
|
||||
resource: URI;
|
||||
@@ -160,13 +162,14 @@ export class ResourcesDropHandler {
|
||||
constructor(
|
||||
private options: IResourcesDropHandlerOptions,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IWindowService private readonly windowService: IWindowService,
|
||||
@IWorkspacesHistoryService private readonly workspacesHistoryService: IWorkspacesHistoryService,
|
||||
@ITextFileService private readonly textFileService: ITextFileService,
|
||||
@IBackupFileService private readonly backupFileService: IBackupFileService,
|
||||
@IUntitledEditorService private readonly untitledEditorService: IUntitledEditorService,
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IWorkspaceEditingService private readonly workspaceEditingService: IWorkspaceEditingService
|
||||
@IWorkspaceEditingService private readonly workspaceEditingService: IWorkspaceEditingService,
|
||||
@IHostService private readonly hostService: IHostService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -177,7 +180,7 @@ export class ResourcesDropHandler {
|
||||
}
|
||||
|
||||
// Make the window active to handle the drop properly within
|
||||
await this.windowService.focusWindow();
|
||||
await this.hostService.focus();
|
||||
|
||||
// Check for special things being dropped
|
||||
const isWorkspaceOpening = await this.doHandleDrop(untitledOrFileResources);
|
||||
@@ -187,9 +190,9 @@ export class ResourcesDropHandler {
|
||||
}
|
||||
|
||||
// Add external ones to recently open list unless dropped resource is a workspace
|
||||
const recents: IRecentFile[] = untitledOrFileResources.filter(d => d.isExternal && d.resource.scheme === Schemas.file).map(d => ({ fileUri: d.resource }));
|
||||
if (recents.length) {
|
||||
this.windowService.addRecentlyOpened(recents);
|
||||
const recentFiles: IRecentFile[] = untitledOrFileResources.filter(d => d.isExternal && d.resource.scheme === Schemas.file).map(d => ({ fileUri: d.resource }));
|
||||
if (recentFiles.length) {
|
||||
this.workspacesHistoryService.addRecentlyOpened(recentFiles);
|
||||
}
|
||||
|
||||
const editors: IResourceEditor[] = untitledOrFileResources.map(untitledOrFileResource => ({
|
||||
@@ -262,14 +265,14 @@ export class ResourcesDropHandler {
|
||||
}
|
||||
|
||||
private async handleWorkspaceFileDrop(fileOnDiskResources: URI[]): Promise<boolean> {
|
||||
const urisToOpen: IURIToOpen[] = [];
|
||||
const toOpen: IWindowOpenable[] = [];
|
||||
const folderURIs: IWorkspaceFolderCreationData[] = [];
|
||||
|
||||
await Promise.all(fileOnDiskResources.map(async fileOnDiskResource => {
|
||||
|
||||
// Check for Workspace
|
||||
if (hasWorkspaceFileExtension(fileOnDiskResource)) {
|
||||
urisToOpen.push({ workspaceUri: fileOnDiskResource });
|
||||
toOpen.push({ workspaceUri: fileOnDiskResource });
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -278,7 +281,7 @@ export class ResourcesDropHandler {
|
||||
try {
|
||||
const stat = await this.fileService.resolve(fileOnDiskResource);
|
||||
if (stat.isDirectory) {
|
||||
urisToOpen.push({ folderUri: stat.resource });
|
||||
toOpen.push({ folderUri: stat.resource });
|
||||
folderURIs.push({ uri: stat.resource });
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -287,16 +290,16 @@ export class ResourcesDropHandler {
|
||||
}));
|
||||
|
||||
// Return early if no external resource is a folder or workspace
|
||||
if (urisToOpen.length === 0) {
|
||||
if (toOpen.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pass focus to window
|
||||
this.windowService.focusWindow();
|
||||
this.hostService.focus();
|
||||
|
||||
// Open in separate windows if we drop workspaces or just one folder
|
||||
if (urisToOpen.length > folderURIs.length || folderURIs.length === 1) {
|
||||
await this.windowService.openWindow(urisToOpen, { forceReuseWindow: true });
|
||||
if (toOpen.length > folderURIs.length || folderURIs.length === 1) {
|
||||
await this.hostService.openInWindow(toOpen, { forceReuseWindow: true });
|
||||
}
|
||||
|
||||
// folders.length > 1: Multiple folders: Create new workspace with folders and open
|
||||
|
||||
Reference in New Issue
Block a user