mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Use classes for drop/paste edit types (#151980)
This commit is contained in:
parent
48cf67d528
commit
7284c3e4c1
|
@ -21,10 +21,7 @@ export function registerPasteProvider(selector: vscode.DocumentSelector) {
|
|||
}
|
||||
|
||||
const snippet = await tryGetUriListSnippet(document, dataTransfer, token);
|
||||
if (snippet) {
|
||||
return { insertText: snippet };
|
||||
}
|
||||
return undefined;
|
||||
return snippet ? new vscode.DocumentPasteEdit(snippet) : undefined;
|
||||
}
|
||||
}, {
|
||||
pasteMimeTypes: ['text/uri-list']
|
||||
|
|
|
@ -32,10 +32,7 @@ export function registerDropIntoEditor(selector: vscode.DocumentSelector) {
|
|||
}
|
||||
|
||||
const snippet = await tryGetUriListSnippet(document, dataTransfer, token);
|
||||
if (snippet) {
|
||||
return { insertText: snippet };
|
||||
}
|
||||
return undefined;
|
||||
return snippet ? new vscode.DocumentDropEdit(snippet) : undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1298,6 +1298,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
|||
ViewColumn: extHostTypes.ViewColumn,
|
||||
WorkspaceEdit: extHostTypes.WorkspaceEdit,
|
||||
// proposed api types
|
||||
DocumentDropEdit: extHostTypes.DocumentDropEdit,
|
||||
DocumentPasteEdit: extHostTypes.DocumentPasteEdit,
|
||||
InlayHint: extHostTypes.InlayHint,
|
||||
InlayHintLabelPart: extHostTypes.InlayHintLabelPart,
|
||||
InlayHintKind: extHostTypes.InlayHintKind,
|
||||
|
|
|
@ -2480,6 +2480,27 @@ export class DataTransfer {
|
|||
}
|
||||
}
|
||||
|
||||
@es5ClassCompat
|
||||
export class DocumentDropEdit {
|
||||
insertText: string | SnippetString;
|
||||
|
||||
additionalEdit?: WorkspaceEdit;
|
||||
|
||||
constructor(insertText: string | SnippetString) {
|
||||
this.insertText = insertText;
|
||||
}
|
||||
}
|
||||
|
||||
@es5ClassCompat
|
||||
export class DocumentPasteEdit {
|
||||
insertText: string | SnippetString;
|
||||
|
||||
additionalEdit?: WorkspaceEdit;
|
||||
|
||||
constructor(insertText: string | SnippetString) {
|
||||
this.insertText = insertText;
|
||||
}
|
||||
}
|
||||
|
||||
@es5ClassCompat
|
||||
export class ThemeIcon {
|
||||
|
|
|
@ -43,7 +43,7 @@ declare module 'vscode' {
|
|||
/**
|
||||
* An operation applied on paste
|
||||
*/
|
||||
interface DocumentPasteEdit {
|
||||
class DocumentPasteEdit {
|
||||
/**
|
||||
* The text or snippet to insert at the pasted locations.
|
||||
*/
|
||||
|
@ -53,6 +53,11 @@ declare module 'vscode' {
|
|||
* An optional additional edit to apply on paste.
|
||||
*/
|
||||
readonly additionalEdit?: WorkspaceEdit;
|
||||
|
||||
/**
|
||||
* @param insertText The text or snippet to insert at the pasted locations.
|
||||
*/
|
||||
constructor(insertText: string | SnippetString);
|
||||
}
|
||||
|
||||
interface DocumentPasteProviderMetadata {
|
||||
|
|
|
@ -30,16 +30,21 @@ declare module 'vscode' {
|
|||
/**
|
||||
* An edit operation applied on drop.
|
||||
*/
|
||||
export interface DocumentDropEdit {
|
||||
export class DocumentDropEdit {
|
||||
/**
|
||||
* The text or snippet to insert at the drop location.
|
||||
*/
|
||||
readonly insertText: string | SnippetString;
|
||||
insertText: string | SnippetString;
|
||||
|
||||
/**
|
||||
* An optional additional edit to apply on drop.
|
||||
*/
|
||||
readonly additionalEdit?: WorkspaceEdit;
|
||||
additionalEdit?: WorkspaceEdit;
|
||||
|
||||
/**
|
||||
* @param insertText The text or snippet to insert at the drop location.
|
||||
*/
|
||||
constructor(insertText: string | SnippetString);
|
||||
}
|
||||
|
||||
export namespace languages {
|
||||
|
|
Loading…
Reference in a new issue