mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
editors - more dnd code polish towards any editor dnd
This commit is contained in:
parent
f2248508a6
commit
856fb393cb
|
@ -13,7 +13,7 @@ import { URI } from 'vs/base/common/uri';
|
|||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { bufferToReadable, VSBuffer } from 'vs/base/common/buffer';
|
||||
import { FileAccess, Schemas } from 'vs/base/common/network';
|
||||
import { IResourceEditorInput, ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IResourceEditorInput } from 'vs/platform/editor/common/editor';
|
||||
import { DataTransfers, IDragAndDropData } from 'vs/base/browser/dnd';
|
||||
import { DragMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { normalizeDriveLetter } from 'vs/base/common/labels';
|
||||
|
@ -25,7 +25,7 @@ import { IEditorIdentifier, GroupIdentifier, IEditorInputFactoryRegistry, Editor
|
|||
import { IEditorService, IResourceEditorInputType } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { Disposable, IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { addDisposableListener, EventType } from 'vs/base/browser/dom';
|
||||
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
|
@ -33,15 +33,7 @@ import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/com
|
|||
import { Emitter } from 'vs/base/common/event';
|
||||
import { NO_TYPE_ID } from 'vs/workbench/services/workingCopy/common/workingCopy';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
|
||||
export interface IDraggedResource {
|
||||
resource: URI;
|
||||
isExternal: boolean;
|
||||
}
|
||||
|
||||
interface ISerializedDraggedResource {
|
||||
resource: string;
|
||||
}
|
||||
import { parse, stringify } from 'vs/base/common/marshalling';
|
||||
|
||||
export class DraggedEditorIdentifier {
|
||||
|
||||
|
@ -53,23 +45,22 @@ export class DraggedEditorGroupIdentifier {
|
|||
constructor(readonly identifier: GroupIdentifier) { }
|
||||
}
|
||||
|
||||
interface IDraggedEditorProps {
|
||||
dirtyContent?: string;
|
||||
encoding?: string;
|
||||
mode?: string;
|
||||
options?: ITextEditorOptions;
|
||||
}
|
||||
|
||||
export interface IDraggedEditor extends IDraggedResource, IDraggedEditorProps { }
|
||||
|
||||
export interface ISerializedDraggedEditor extends ISerializedDraggedResource, IDraggedEditorProps { }
|
||||
|
||||
export const CodeDataTransfers = {
|
||||
EDITORS: 'CodeEditors',
|
||||
FILES: 'CodeFiles'
|
||||
};
|
||||
|
||||
export function extractResources(e: DragEvent, externalOnly?: boolean): Array<IDraggedResource | IDraggedEditor> {
|
||||
interface IDraggedResource {
|
||||
resource: URI;
|
||||
isExternal?: boolean;
|
||||
}
|
||||
|
||||
interface IDraggedEditor extends IResourceEditorInput {
|
||||
contents?: string;
|
||||
isExternal?: boolean;
|
||||
}
|
||||
|
||||
export function extractResourceDropTransfers(e: DragEvent, externalOnly?: boolean): Array<IDraggedResource | IDraggedEditor> {
|
||||
const resources: Array<IDraggedResource | IDraggedEditor> = [];
|
||||
if (e.dataTransfer && e.dataTransfer.types.length > 0) {
|
||||
|
||||
|
@ -80,17 +71,7 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): Array<ID
|
|||
const rawEditorsData = e.dataTransfer.getData(CodeDataTransfers.EDITORS);
|
||||
if (rawEditorsData) {
|
||||
try {
|
||||
const draggedEditors: ISerializedDraggedEditor[] = JSON.parse(rawEditorsData);
|
||||
draggedEditors.forEach(draggedEditor => {
|
||||
resources.push({
|
||||
resource: URI.parse(draggedEditor.resource),
|
||||
dirtyContent: draggedEditor.dirtyContent,
|
||||
options: draggedEditor.options,
|
||||
encoding: draggedEditor.encoding,
|
||||
mode: draggedEditor.mode,
|
||||
isExternal: false
|
||||
});
|
||||
});
|
||||
resources.push(...parse(rawEditorsData));
|
||||
} catch (error) {
|
||||
// Invalid transfer
|
||||
}
|
||||
|
@ -171,7 +152,7 @@ export class ResourcesDropHandler {
|
|||
}
|
||||
|
||||
async handleDrop(event: DragEvent, resolveTargetGroup: () => IEditorGroup | undefined, afterDrop: (targetGroup: IEditorGroup | undefined) => void, targetIndex?: number): Promise<void> {
|
||||
const untitledOrFileResources = extractResources(event).filter(resource => this.fileService.canHandleResource(resource.resource) || resource.resource.scheme === Schemas.untitled);
|
||||
const untitledOrFileResources = extractResourceDropTransfers(event).filter(resource => this.fileService.canHandleResource(resource.resource) || resource.resource.scheme === Schemas.untitled);
|
||||
if (!untitledOrFileResources.length) {
|
||||
return;
|
||||
}
|
||||
|
@ -213,7 +194,7 @@ export class ResourcesDropHandler {
|
|||
private async doHandleDrop(untitledOrFileResources: Array<IDraggedResource | IDraggedEditor>): Promise<boolean> {
|
||||
|
||||
// Check for dirty editors being dropped
|
||||
const dirtyEditors: IDraggedEditor[] = untitledOrFileResources.filter(untitledOrFileResource => !untitledOrFileResource.isExternal && typeof (untitledOrFileResource as IDraggedEditor).dirtyContent === 'string');
|
||||
const dirtyEditors: IDraggedEditor[] = untitledOrFileResources.filter(untitledOrFileResource => !untitledOrFileResource.isExternal && typeof (untitledOrFileResource as IDraggedEditor).contents === 'string');
|
||||
if (dirtyEditors.length > 0) {
|
||||
await Promise.all(dirtyEditors.map(dirtyEditor => this.handleDirtyEditorDrop(dirtyEditor)));
|
||||
return false;
|
||||
|
@ -237,7 +218,10 @@ export class ResourcesDropHandler {
|
|||
if (droppedDirtyEditor.resource.scheme === Schemas.untitled) {
|
||||
const untitledTextEditorResource = this.editorService.createEditorInput({ mode: droppedDirtyEditor.mode, encoding: droppedDirtyEditor.encoding, forceUntitled: true }).resource;
|
||||
if (untitledTextEditorResource) {
|
||||
droppedDirtyEditor.resource = untitledTextEditorResource;
|
||||
droppedDirtyEditor = {
|
||||
...droppedDirtyEditor,
|
||||
resource: untitledTextEditorResource
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,9 +232,9 @@ export class ResourcesDropHandler {
|
|||
|
||||
// If the dropped editor is dirty with content we simply take that
|
||||
// content and turn it into a backup so that it loads the contents
|
||||
if (typeof droppedDirtyEditor.dirtyContent === 'string') {
|
||||
if (typeof droppedDirtyEditor.contents === 'string') {
|
||||
try {
|
||||
await this.workingCopyBackupService.backup({ resource: droppedDirtyEditor.resource, typeId: NO_TYPE_ID }, bufferToReadable(VSBuffer.fromString(droppedDirtyEditor.dirtyContent)));
|
||||
await this.workingCopyBackupService.backup({ resource: droppedDirtyEditor.resource, typeId: NO_TYPE_ID }, bufferToReadable(VSBuffer.fromString(droppedDirtyEditor.contents)));
|
||||
} catch (e) {
|
||||
// Ignore error
|
||||
}
|
||||
|
@ -311,10 +295,10 @@ interface IResourceStat {
|
|||
isDirectory?: boolean;
|
||||
}
|
||||
|
||||
export function fillResourceDataTransfers(accessor: ServicesAccessor, resources: URI[], event: DragMouseEvent | DragEvent): void;
|
||||
export function fillResourceDataTransfers(accessor: ServicesAccessor, resources: IResourceStat[], event: DragMouseEvent | DragEvent): void;
|
||||
export function fillResourceDataTransfers(accessor: ServicesAccessor, editors: IEditorIdentifier[], event: DragMouseEvent | DragEvent): void;
|
||||
export function fillResourceDataTransfers(accessor: ServicesAccessor, resourcesOrEditors: Array<URI | IResourceStat | IEditorIdentifier>, event: DragMouseEvent | DragEvent): void {
|
||||
export function fillResourceDragTransfers(accessor: ServicesAccessor, resources: URI[], event: DragMouseEvent | DragEvent): void;
|
||||
export function fillResourceDragTransfers(accessor: ServicesAccessor, resources: IResourceStat[], event: DragMouseEvent | DragEvent): void;
|
||||
export function fillResourceDragTransfers(accessor: ServicesAccessor, editors: IEditorIdentifier[], event: DragMouseEvent | DragEvent): void;
|
||||
export function fillResourceDragTransfers(accessor: ServicesAccessor, resourcesOrEditors: Array<URI | IResourceStat | IEditorIdentifier>, event: DragMouseEvent | DragEvent): void {
|
||||
if (resourcesOrEditors.length === 0 || !event.dataTransfer) {
|
||||
return;
|
||||
}
|
||||
|
@ -356,80 +340,74 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resourcesO
|
|||
// into the editor area while presering UI state
|
||||
const textFileService = accessor.get(ITextFileService);
|
||||
const editorService = accessor.get(IEditorService);
|
||||
const editorGroupService = accessor.get(IEditorGroupsService);
|
||||
|
||||
const draggedEditors: ISerializedDraggedEditor[] = [];
|
||||
const draggedEditors: IDraggedEditor[] = [];
|
||||
|
||||
for (const resourceOrEditor of resourcesOrEditors) {
|
||||
|
||||
// Extract resource editor from provided object or URI
|
||||
let editor: IResourceEditorInput;
|
||||
let editor: IResourceEditorInput | undefined = undefined;
|
||||
if (isEditorIdentifier(resourceOrEditor)) {
|
||||
const editorCandidate = resourceOrEditor.editor.asResourceEditorInput(resourceOrEditor.groupId);
|
||||
if (!editorCandidate) {
|
||||
return; // not transferable editor (not serializable)
|
||||
}
|
||||
|
||||
editor = editorCandidate;
|
||||
|
||||
if (!editor.options?.viewState) {
|
||||
const group = editorGroupService.getGroup(resourceOrEditor.groupId);
|
||||
if (group?.activeEditor === resourceOrEditor.editor) {
|
||||
const activeControl = group.activeEditorPane?.getControl();
|
||||
if (isCodeEditor(activeControl)) {
|
||||
editor.options = {
|
||||
...editor.options,
|
||||
viewState: withNullAsUndefined(activeControl.saveViewState())
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
editor = resourceOrEditor.editor.asResourceEditorInput(resourceOrEditor.groupId);
|
||||
} else {
|
||||
const editorCandidate = URI.isUri(resourceOrEditor) ? { resource: resourceOrEditor } : !resourceOrEditor.isDirectory ? { resource: resourceOrEditor.resource } : undefined;
|
||||
if (!editorCandidate) {
|
||||
return; // not transferable editor (directory)
|
||||
let resource: URI | undefined = undefined;
|
||||
if (URI.isUri(resourceOrEditor)) {
|
||||
resource = resourceOrEditor;
|
||||
} else if (!resourceOrEditor.isDirectory) {
|
||||
resource = resourceOrEditor.resource;
|
||||
}
|
||||
|
||||
editor = editorCandidate;
|
||||
if (!resource) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const textEditorControl of editorService.visibleTextEditorControls) {
|
||||
if (isCodeEditor(textEditorControl)) {
|
||||
const model = textEditorControl.getModel();
|
||||
if (isEqual(model?.uri, editor.resource)) {
|
||||
editor.options = {
|
||||
...editor.options,
|
||||
viewState: withNullAsUndefined(textEditorControl.saveViewState())
|
||||
};
|
||||
// If we only got a resource to work with, try to resolve as many
|
||||
// editor properties as possible. This currently only works with
|
||||
// text editors and not custom editors.
|
||||
const model = resource.scheme === Schemas.untitled ? textFileService.untitled.get(resource) : textFileService.files.get(resource);
|
||||
|
||||
break;
|
||||
}
|
||||
editor = {
|
||||
resource,
|
||||
encoding: model?.getEncoding(),
|
||||
mode: model?.getMode(),
|
||||
options: {
|
||||
viewState: (() => {
|
||||
for (const textEditorControl of editorService.visibleTextEditorControls) {
|
||||
if (isCodeEditor(textEditorControl)) {
|
||||
const model = textEditorControl.getModel();
|
||||
if (isEqual(model?.uri, resource)) {
|
||||
return withNullAsUndefined(textEditorControl.saveViewState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
})()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Try to find encoding and mode from text model if any
|
||||
let encoding: string | undefined = undefined;
|
||||
let mode: string | undefined = undefined;
|
||||
|
||||
const model = editor.resource.scheme === Schemas.untitled ? textFileService.untitled.get(editor.resource) : textFileService.files.get(editor.resource);
|
||||
if (model) {
|
||||
encoding = model.getEncoding();
|
||||
mode = model.getMode();
|
||||
}
|
||||
|
||||
// If the resource is dirty or untitled, send over its content
|
||||
// to restore dirty state. Get that from the text model directly
|
||||
let dirtyContent: string | undefined = undefined;
|
||||
if (model?.isDirty()) {
|
||||
dirtyContent = model.textEditorModel.getValue();
|
||||
if (!editor) {
|
||||
continue; // skip over editors that cannot be transferred via dnd
|
||||
}
|
||||
|
||||
// Add as dragged editor
|
||||
draggedEditors.push({ resource: editor.resource.toString(), dirtyContent, options: editor.options, encoding, mode });
|
||||
draggedEditors.push({
|
||||
...editor,
|
||||
contents: (() => {
|
||||
// TODO@bpasero this should not happen from here but from the asResourceEditorInput() method
|
||||
const model = editor.resource.scheme === Schemas.untitled ? textFileService.untitled.get(editor.resource) : textFileService.files.get(editor.resource);
|
||||
if (model?.isDirty()) {
|
||||
return model.textEditorModel.getValue();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
})()
|
||||
});
|
||||
}
|
||||
|
||||
if (draggedEditors.length) {
|
||||
event.dataTransfer.setData(CodeDataTransfers.EDITORS, JSON.stringify(draggedEditors));
|
||||
event.dataTransfer.setData(CodeDataTransfers.EDITORS, stringify(draggedEditors));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
|||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { listActiveSelectionBackground, listActiveSelectionForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { IThemeService, registerThemingParticipant, Themable } from 'vs/platform/theme/common/themeService';
|
||||
import { DraggedEditorGroupIdentifier, DraggedEditorIdentifier, fillResourceDataTransfers, LocalSelectionTransfer } from 'vs/workbench/browser/dnd';
|
||||
import { DraggedEditorGroupIdentifier, DraggedEditorIdentifier, fillResourceDragTransfers, LocalSelectionTransfer } from 'vs/workbench/browser/dnd';
|
||||
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
||||
import { BreadcrumbsConfig } from 'vs/workbench/browser/parts/editor/breadcrumbs';
|
||||
import { BreadcrumbsControl, IBreadcrumbsControlOptions } from 'vs/workbench/browser/parts/editor/breadcrumbsControl';
|
||||
|
@ -289,7 +289,7 @@ export abstract class TitleControl extends Themable {
|
|||
|
||||
protected doFillResourceDataTransfers(editors: readonly IEditorInput[], e: DragEvent): boolean {
|
||||
if (editors.length) {
|
||||
this.instantiationService.invokeFunction(fillResourceDataTransfers, editors.map(editor => ({ editor, groupId: this.group.id })), e);
|
||||
this.instantiationService.invokeFunction(fillResourceDragTransfers, editors.map(editor => ({ editor, groupId: this.group.id })), e);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { GroupIdentifier, IEditorInput, IRevertOptions } from 'vs/workbench/common/editor';
|
||||
import { GroupIdentifier, IEditorInput, IRevertOptions, isTextEditorPane } from 'vs/workbench/common/editor';
|
||||
import { AbstractResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ITextFileService, ITextFileSaveOptions, IModeSupport } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
|
@ -15,6 +15,7 @@ import { isEqual } from 'vs/base/common/resources';
|
|||
import { ITextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { TextResourceEditorModel } from 'vs/workbench/common/editor/textResourceEditorModel';
|
||||
import { IReference } from 'vs/base/common/lifecycle';
|
||||
import { IEditorViewState } from 'vs/editor/common/editorCommon';
|
||||
|
||||
/**
|
||||
* The base class for all editor inputs that open in text editors.
|
||||
|
@ -78,6 +79,18 @@ export abstract class AbstractTextResourceEditorInput extends AbstractResourceEd
|
|||
override async revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {
|
||||
await this.textFileService.revert(this.resource, options);
|
||||
}
|
||||
|
||||
protected getViewStateFor(group: GroupIdentifier): IEditorViewState | undefined {
|
||||
for (const editorPane of this.editorService.visibleEditorPanes) {
|
||||
if (editorPane.group.id === group && this.matches(editorPane.input)) {
|
||||
if (isTextEditorPane(editorPane)) {
|
||||
return editorPane.getViewState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IFileEditorInput, Verbosity, GroupIdentifier, IMoveResult, isTextEditorPane, EditorInputCapabilities, IEditorDescriptor, IEditorPane } from 'vs/workbench/common/editor';
|
||||
import { IFileEditorInput, Verbosity, GroupIdentifier, IMoveResult, EditorInputCapabilities, IEditorDescriptor, IEditorPane } from 'vs/workbench/common/editor';
|
||||
import { AbstractTextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput';
|
||||
import { IResourceEditorInput } from 'vs/platform/editor/common/editor';
|
||||
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
|
||||
|
@ -19,7 +19,6 @@ import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/
|
|||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { isEqual } from 'vs/base/common/resources';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IEditorViewState } from 'vs/editor/common/editorCommon';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
const enum ForceOpenAs {
|
||||
|
@ -211,6 +210,14 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
|
|||
this.setForceOpenAsText();
|
||||
}
|
||||
|
||||
getMode(): string | undefined {
|
||||
if (this.model) {
|
||||
return this.model.getMode();
|
||||
}
|
||||
|
||||
return this.preferredMode;
|
||||
}
|
||||
|
||||
getPreferredMode(): string | undefined {
|
||||
return this.preferredMode;
|
||||
}
|
||||
|
@ -353,21 +360,14 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
|
|||
};
|
||||
}
|
||||
|
||||
private getViewStateFor(group: GroupIdentifier): IEditorViewState | undefined {
|
||||
for (const editorPane of this.editorService.visibleEditorPanes) {
|
||||
if (editorPane.group.id === group && this.matches(editorPane.input)) {
|
||||
if (isTextEditorPane(editorPane)) {
|
||||
return editorPane.getViewState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
override asResourceEditorInput(groupId: GroupIdentifier): IResourceEditorInput | undefined {
|
||||
override asResourceEditorInput(group: GroupIdentifier): IResourceEditorInput | undefined {
|
||||
return {
|
||||
resource: this.preferredResource
|
||||
resource: this.preferredResource,
|
||||
encoding: this.getEncoding(),
|
||||
mode: this.getMode(),
|
||||
options: {
|
||||
viewState: this.getViewStateFor(group)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import { ExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
|
|||
import { URI } from 'vs/base/common/uri';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { extractResources } from 'vs/workbench/browser/dnd';
|
||||
import { extractResourceDropTransfers } from 'vs/workbench/browser/dnd';
|
||||
import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing';
|
||||
import { isWeb } from 'vs/base/common/platform';
|
||||
import { triggerDownload, WebFileSystemAccess } from 'vs/base/browser/dom';
|
||||
|
@ -418,7 +418,7 @@ export class NativeFileImport {
|
|||
private async doImport(target: ExplorerItem, source: DragEvent, token: CancellationToken): Promise<void> {
|
||||
|
||||
// Check for dropped external files to be folders
|
||||
const droppedResources = extractResources(source, true);
|
||||
const droppedResources = extractResourceDropTransfers(source, true);
|
||||
const resolvedFiles = await this.fileService.resolveAll(droppedResources.map(droppedResource => ({ resource: droppedResource.resource })));
|
||||
|
||||
if (token.isCancellationRequested) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import { equals, deepClone } from 'vs/base/common/objects';
|
|||
import * as path from 'vs/base/common/path';
|
||||
import { ExplorerItem, NewExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
|
||||
import { compareFileExtensionsDefault, compareFileNamesDefault, compareFileNamesUpper, compareFileExtensionsUpper, compareFileNamesLower, compareFileExtensionsLower, compareFileNamesUnicode, compareFileExtensionsUnicode } from 'vs/base/common/comparers';
|
||||
import { fillResourceDataTransfers, CodeDataTransfers, containsDragType } from 'vs/workbench/browser/dnd';
|
||||
import { fillResourceDragTransfers, CodeDataTransfers, containsDragType } from 'vs/workbench/browser/dnd';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDragAndDropData, DataTransfers } from 'vs/base/browser/dnd';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
@ -928,7 +928,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
|
|||
const items = FileDragAndDrop.getStatsFromDragAndDropData(data as ElementsDragAndDropData<ExplorerItem, ExplorerItem[]>, originalEvent);
|
||||
if (items && items.length && originalEvent.dataTransfer) {
|
||||
// Apply some datatransfer types to allow for dragging the element outside of the application
|
||||
this.instantiationService.invokeFunction(accessor => fillResourceDataTransfers(accessor, items, originalEvent));
|
||||
this.instantiationService.invokeFunction(accessor => fillResourceDragTransfers(accessor, items, originalEvent));
|
||||
|
||||
// The only custom data transfer we set from the explorer is a file transfer
|
||||
// to be able to DND between multiple code file explorers across windows
|
||||
|
|
|
@ -32,7 +32,7 @@ import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/m
|
|||
import { IMenuService, MenuId, IMenu, Action2, registerAction2, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { OpenEditorsDirtyEditorContext, OpenEditorsGroupContext, OpenEditorsReadonlyEditorContext, SAVE_ALL_LABEL, SAVE_ALL_COMMAND_ID, NEW_UNTITLED_FILE_COMMAND_ID } from 'vs/workbench/contrib/files/browser/fileCommands';
|
||||
import { ResourceContextKey } from 'vs/workbench/common/resources';
|
||||
import { ResourcesDropHandler, fillResourceDataTransfers, CodeDataTransfers, containsDragType } from 'vs/workbench/browser/dnd';
|
||||
import { ResourcesDropHandler, fillResourceDragTransfers, CodeDataTransfers, containsDragType } from 'vs/workbench/browser/dnd';
|
||||
import { ViewPane } from 'vs/workbench/browser/parts/views/viewPane';
|
||||
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
|
||||
import { IDragAndDropData, DataTransfers } from 'vs/base/browser/dnd';
|
||||
|
@ -663,7 +663,7 @@ class OpenEditorsDragAndDrop implements IListDragAndDrop<OpenEditor | IEditorGro
|
|||
|
||||
if (editors.length) {
|
||||
// Apply some datatransfer types to allow for dragging the element outside of the application
|
||||
this.instantiationService.invokeFunction(fillResourceDataTransfers, editors, originalEvent);
|
||||
this.instantiationService.invokeFunction(fillResourceDragTransfers, editors, originalEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import { Action, IAction } from 'vs/base/common/actions';
|
|||
import { localize } from 'vs/nls';
|
||||
import { IDragAndDropData } from 'vs/base/browser/dnd';
|
||||
import { ElementsDragAndDropData } from 'vs/base/browser/ui/list/listView';
|
||||
import { fillResourceDataTransfers } from 'vs/workbench/browser/dnd';
|
||||
import { fillResourceDragTransfers } from 'vs/workbench/browser/dnd';
|
||||
import { CancelablePromise, createCancelablePromise, Delayer } from 'vs/base/common/async';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
|
@ -898,7 +898,7 @@ export class ResourceDragAndDrop implements ITreeDragAndDrop<MarkerElement> {
|
|||
|
||||
if (resources.length) {
|
||||
// Apply some datatransfer types to allow for dragging the element outside of the application
|
||||
this.instantiationService.invokeFunction(accessor => fillResourceDataTransfers(accessor, resources, originalEvent));
|
||||
this.instantiationService.invokeFunction(accessor => fillResourceDragTransfers(accessor, resources, originalEvent));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import { RemoveAction, ReplaceAction, ReplaceAllAction, ReplaceAllInFolderAction
|
|||
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
|
||||
import { FileMatch, Match, RenderableMatch, SearchModel, FolderMatch } from 'vs/workbench/contrib/search/common/searchModel';
|
||||
import { IDragAndDropData } from 'vs/base/browser/dnd';
|
||||
import { fillResourceDataTransfers } from 'vs/workbench/browser/dnd';
|
||||
import { fillResourceDragTransfers } from 'vs/workbench/browser/dnd';
|
||||
import { ElementsDragAndDropData } from 'vs/base/browser/ui/list/listView';
|
||||
|
||||
interface IFolderMatchTemplate {
|
||||
|
@ -377,7 +377,7 @@ export class SearchDND implements ITreeDragAndDrop<RenderableMatch> {
|
|||
|
||||
if (resources.length) {
|
||||
// Apply some datatransfer types to allow for dragging the element outside of the application
|
||||
this.instantiationService.invokeFunction(accessor => fillResourceDataTransfers(accessor, resources, originalEvent));
|
||||
this.instantiationService.invokeFunction(accessor => fillResourceDragTransfers(accessor, resources, originalEvent));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,9 +116,14 @@ export class UntitledTextEditorInput extends AbstractTextResourceEditorInput imp
|
|||
return this.model;
|
||||
}
|
||||
|
||||
override asResourceEditorInput(groupId: GroupIdentifier): IResourceEditorInput | undefined {
|
||||
override asResourceEditorInput(group: GroupIdentifier): IResourceEditorInput | undefined {
|
||||
return {
|
||||
resource: this.model.resource
|
||||
resource: this.model.resource,
|
||||
encoding: this.getEncoding(),
|
||||
mode: this.getMode(),
|
||||
options: {
|
||||
viewState: this.getViewStateFor(group)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue