Better handling of text/uri-list in built-in extensions (#153163)

- When splitting `text/uri-list`, we should split on `\n` to handle against spec versions of `text/uri-list`
- However when constructing a `text/uri-list`, we should use `\r\n` to align with the spec
This commit is contained in:
Matt Bierner 2022-06-24 15:24:16 -07:00 committed by GitHub
parent fff8f8ace5
commit 64305a732e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View file

@ -44,7 +44,7 @@ export async function tryGetUriListSnippet(document: vscode.TextDocument, dataTr
}
const uris: vscode.Uri[] = [];
for (const resource of urlList.split('\r\n')) {
for (const resource of urlList.split('\n')) {
try {
uris.push(vscode.Uri.parse(resource));
} catch {

View file

@ -213,7 +213,7 @@ class TreeDndDelegate implements vscode.TreeDragAndDropController<undefined> {
}
}
if (urls.length > 0) {
data.set('text/uri-list', new vscode.DataTransferItem(urls.join('\n')));
data.set('text/uri-list', new vscode.DataTransferItem(urls.join('\r\n')));
}
}
}

View file

@ -119,7 +119,7 @@ class DefaultOnDropProvider implements DocumentOnDropEditProvider {
) { }
async provideDocumentOnDropEdits(_model: ITextModel, _position: IPosition, dataTransfer: VSDataTransfer, _token: CancellationToken): Promise<DocumentOnDropEdit | undefined> {
const urlListEntry = dataTransfer.get('text/uri-list');
const urlListEntry = dataTransfer.get(Mimes.uriList);
if (urlListEntry) {
const urlList = await urlListEntry.asString();
const snippet = this.getUriListInsertText(urlList);

View file

@ -10127,7 +10127,7 @@ declare module 'vscode' {
* @param mimeType The mime type to get the data transfer item for, such as `text/plain` or `image/png`.
*
* Special mime types:
* - `text/uri-list`  A string with `toString()`ed Uris separated by newlines. To specify a cursor position in the file,
* - `text/uri-list`  A string with `toString()`ed Uris separated by `\r\n`. To specify a cursor position in the file,
* set the Uri's fragment to `L3,5`, where 3 is the line number and 5 is the column number.
*/
get(mimeType: string): DataTransferItem | undefined;