Update text editor drop proposal (#151552)

This updates the text editor drop proposal (#142990). This change introduces `DocumentDropEdit` which removes the need for `SnippetTextEdit`. This interface may also be extended in the future with additional metadata
This commit is contained in:
Matt Bierner
2022-06-08 14:44:28 -07:00
committed by GitHub
parent 83b94a5c03
commit d7c90c2b2b
13 changed files with 79 additions and 78 deletions

View File

@@ -25,16 +25,15 @@ const imageFileExtensions = new Set<string>([
export function registerDropIntoEditor(selector: vscode.DocumentSelector) {
return vscode.languages.registerDocumentOnDropEditProvider(selector, new class implements vscode.DocumentOnDropEditProvider {
async provideDocumentOnDropEdits(document: vscode.TextDocument, position: vscode.Position, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.SnippetTextEdit | undefined> {
async provideDocumentOnDropEdits(document: vscode.TextDocument, _position: vscode.Position, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.DocumentDropEdit | undefined> {
const enabled = vscode.workspace.getConfiguration('markdown', document).get('editor.drop.enabled', true);
if (!enabled) {
return undefined;
}
const replacementRange = new vscode.Range(position, position);
const snippet = await tryGetUriListSnippet(document, dataTransfer, token);
if (snippet) {
return new vscode.SnippetTextEdit(replacementRange, snippet);
return { insertText: snippet };
}
return undefined;
}