Adopt SnippetTextEdit for drop

This commit is contained in:
Matt Bierner 2022-04-01 11:43:50 -07:00
parent 41e7b85195
commit 5451119820
No known key found for this signature in database
GPG key ID: 099C331567E11888
2 changed files with 4 additions and 7 deletions

View file

@ -9,10 +9,10 @@ import * as URI from 'vscode-uri';
export function registerDropIntoEditor() {
return vscode.workspace.onWillDropOnTextEditor(e => {
e.waitUntil((async () => {
e.waitUntil((async (): Promise<vscode.SnippetTextEdit | undefined> => {
const urlList = await e.dataTransfer.get('text/uri-list')?.asString();
if (!urlList) {
return;
return undefined;
}
const uris: vscode.Uri[] = [];
@ -41,7 +41,7 @@ export function registerDropIntoEditor() {
}
});
return e.editor.insertSnippet(snippet, e.position);
return new vscode.SnippetTextEdit(new vscode.Range(e.position, e.position), snippet);
})());
});
}

View file

@ -48,10 +48,7 @@ declare module 'vscode' {
*
* @param thenable A thenable that delays saving.
*/
waitUntil(thenable: Thenable<any>): void;
//
waitUntil(thenable: Thenable<SnippetTextEdit>): void;
waitUntil(thenable: Thenable<SnippetTextEdit | undefined>): void;
token: CancellationToken;
}