Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DataTransferItem.kind #151384

Merged
merged 1 commit into from Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Expand Up @@ -1330,6 +1330,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
TextSearchCompleteMessageType: TextSearchCompleteMessageType,
DataTransfer: extHostTypes.DataTransfer,
DataTransferItem: extHostTypes.DataTransferItem,
DataTransferItemKind: extHostTypes.DataTransferItemKind,
CoveredCount: extHostTypes.CoveredCount,
FileCoverage: extHostTypes.FileCoverage,
StatementCoverage: extHostTypes.StatementCoverage,
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/api/common/extHostTypeConverters.ts
Expand Up @@ -1965,6 +1965,8 @@ export namespace DataTransferItem {
const file = item.fileData;
if (file) {
return new class extends types.DataTransferItem {
override get kind() { return types.DataTransferItemKind.File; }

override asFile(): vscode.DataTransferFile {
return {
name: file.name,
Expand Down
8 changes: 8 additions & 0 deletions src/vs/workbench/api/common/extHostTypes.ts
Expand Up @@ -2438,8 +2438,16 @@ export enum TreeItemCollapsibleState {
Expanded = 2
}

export enum DataTransferItemKind {
String = 1,
File = 2,
}

@es5ClassCompat
export class DataTransferItem {

get kind(): DataTransferItemKind { return DataTransferItemKind.String; }

async asString(): Promise<string> {
return typeof this.value === 'string' ? this.value : JSON.stringify(this.value);
}
Expand Down
9 changes: 9 additions & 0 deletions src/vscode-dts/vscode.proposed.dataTransferFiles.d.ts
Expand Up @@ -7,6 +7,15 @@ declare module 'vscode' {

// https://github.com/microsoft/vscode/issues/147481

enum DataTransferItemKind {
String = 1,
File = 2,
}

interface DataTransferItem {
readonly kind: DataTransferItemKind;
}

/**
* A file associated with a {@linkcode DataTransferItem}.
*/
Expand Down