mirror of
https://github.com/coder/code-server.git
synced 2026-06-04 11:29:34 +00:00
chore(vscode): update to 1.56.0
This commit is contained in:
@@ -3,13 +3,15 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { hasWorkspaceFileExtension, IWorkspaceFolderCreationData, IRecentFile, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { normalize } from 'vs/base/common/path';
|
||||
import { basename, isEqual } from 'vs/base/common/resources';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IWindowOpenable } from 'vs/platform/windows/common/windows';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ITextFileService, stringToSnapshot } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
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 { ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { DataTransfers, IDragAndDropData } from 'vs/base/browser/dnd';
|
||||
@@ -19,7 +21,7 @@ import { MIME_BINARY } from 'vs/base/common/mime';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IEditorIdentifier, GroupIdentifier } from 'vs/workbench/common/editor';
|
||||
import { IEditorIdentifier, GroupIdentifier, IEditorInputFactoryRegistry, EditorExtensions } from 'vs/workbench/common/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';
|
||||
@@ -27,8 +29,9 @@ import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsSe
|
||||
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';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { NO_TYPE_ID } from 'vs/workbench/services/workingCopy/common/workingCopy';
|
||||
|
||||
export interface IDraggedResource {
|
||||
resource: URI;
|
||||
@@ -110,7 +113,7 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): Array<ID
|
||||
if (e.dataTransfer && e.dataTransfer.files) {
|
||||
for (let i = 0; i < e.dataTransfer.files.length; i++) {
|
||||
const file = e.dataTransfer.files[i];
|
||||
if (file?.path /* Electron only */ && !resources.some(r => r.resource.fsPath === file.path) /* prevent duplicates */) {
|
||||
if (file?.path /* Electron only */ && !resources.some(resource => resource.resource.fsPath === file.path) /* prevent duplicates */) {
|
||||
try {
|
||||
resources.push({ resource: URI.file(file.path), isExternal: true });
|
||||
} catch (error) {
|
||||
@@ -126,7 +129,7 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): Array<ID
|
||||
try {
|
||||
const codeFiles: string[] = JSON.parse(rawCodeFiles);
|
||||
codeFiles.forEach(codeFile => {
|
||||
if (!resources.some(r => r.resource.fsPath === codeFile) /* prevent duplicates */) {
|
||||
if (!resources.some(resource => resource.resource.fsPath === codeFile) /* prevent duplicates */) {
|
||||
resources.push({ resource: URI.file(codeFile), isExternal: true });
|
||||
}
|
||||
});
|
||||
@@ -159,7 +162,7 @@ export class ResourcesDropHandler {
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IWorkspacesService private readonly workspacesService: IWorkspacesService,
|
||||
@ITextFileService private readonly textFileService: ITextFileService,
|
||||
@IBackupFileService private readonly backupFileService: IBackupFileService,
|
||||
@IWorkingCopyBackupService private readonly workingCopyBackupService: IWorkingCopyBackupService,
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IWorkspaceEditingService private readonly workspaceEditingService: IWorkspaceEditingService,
|
||||
@IHostService private readonly hostService: IHostService
|
||||
@@ -167,7 +170,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(r => this.fileService.canHandleResource(r.resource) || r.resource.scheme === Schemas.untitled);
|
||||
const untitledOrFileResources = extractResources(event).filter(resource => this.fileService.canHandleResource(resource.resource) || resource.resource.scheme === Schemas.untitled);
|
||||
if (!untitledOrFileResources.length) {
|
||||
return;
|
||||
}
|
||||
@@ -227,6 +230,7 @@ export class ResourcesDropHandler {
|
||||
}
|
||||
|
||||
private async handleDirtyEditorDrop(droppedDirtyEditor: IDraggedEditor): Promise<boolean> {
|
||||
const fileEditorFactory = Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).getFileEditorInputFactory();
|
||||
|
||||
// Untitled: always ensure that we open a new untitled editor for each file we drop
|
||||
if (droppedDirtyEditor.resource.scheme === Schemas.untitled) {
|
||||
@@ -237,7 +241,7 @@ export class ResourcesDropHandler {
|
||||
}
|
||||
|
||||
// File: ensure the file is not dirty or opened already
|
||||
else if (this.textFileService.isDirty(droppedDirtyEditor.resource) || this.editorService.isOpen({ resource: droppedDirtyEditor.resource })) {
|
||||
else if (this.textFileService.isDirty(droppedDirtyEditor.resource) || this.editorService.isOpened({ resource: droppedDirtyEditor.resource, typeId: fileEditorFactory.typeId })) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -245,7 +249,7 @@ export class ResourcesDropHandler {
|
||||
// content and turn it into a backup so that it loads the contents
|
||||
if (typeof droppedDirtyEditor.dirtyContent === 'string') {
|
||||
try {
|
||||
await this.backupFileService.backup(droppedDirtyEditor.resource, stringToSnapshot(droppedDirtyEditor.dirtyContent));
|
||||
await this.workingCopyBackupService.backup({ resource: droppedDirtyEditor.resource, typeId: NO_TYPE_ID }, bufferToReadable(VSBuffer.fromString(droppedDirtyEditor.dirtyContent)));
|
||||
} catch (e) {
|
||||
// Ignore error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user