From 0f0e8bf618dc37ceaa46eb6efe5b6f9e56be3bca Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Sun, 31 Mar 2024 22:18:43 -0700 Subject: [PATCH] Limit drop bail out to just http(s) uris Fixes #209239 The previous check was too broad and caused us to bail when pasting `file` uris. The specific case this code was trying to work around was copy/pasting from the browser address bar, which should almost always be a http or https uri --- .../languageFeatures/copyFiles/dropOrPasteResource.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/markdown-language-features/src/languageFeatures/copyFiles/dropOrPasteResource.ts b/extensions/markdown-language-features/src/languageFeatures/copyFiles/dropOrPasteResource.ts index 73a012dacecce..ef5310013b83a 100644 --- a/extensions/markdown-language-features/src/languageFeatures/copyFiles/dropOrPasteResource.ts +++ b/extensions/markdown-language-features/src/languageFeatures/copyFiles/dropOrPasteResource.ts @@ -156,9 +156,14 @@ class ResourcePasteOrDropProvider implements vscode.DocumentPasteEditProvider, v return; } - // Disable ourselves if there's also a text entry with the same content as our list, + // In some browsers, copying from the address bar sets both text/uri-list and text/plain. + // Disable ourselves if there's also a text entry with the same http(s) uri as our list, // unless we are explicitly requested. - if (uriList.entries.length === 1 && !context?.only?.contains(ResourcePasteOrDropProvider.kind)) { + if ( + uriList.entries.length === 1 + && (uriList.entries[0].uri.scheme === Schemes.http || uriList.entries[0].uri.scheme === Schemes.https) + && !context?.only?.contains(ResourcePasteOrDropProvider.kind) + ) { const text = await dataTransfer.get(Mime.textPlain)?.asString(); if (token.isCancellationRequested) { return;