Skip to content

Commit f776fed

Browse files
authored
Limit drop bail out to just http(s) uris (microsoft#209241)
Fixes microsoft#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
1 parent d994aed commit f776fed

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

extensions/markdown-language-features/src/languageFeatures/copyFiles/dropOrPasteResource.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,14 @@ class ResourcePasteOrDropProvider implements vscode.DocumentPasteEditProvider, v
156156
return;
157157
}
158158

159-
// Disable ourselves if there's also a text entry with the same content as our list,
159+
// In some browsers, copying from the address bar sets both text/uri-list and text/plain.
160+
// Disable ourselves if there's also a text entry with the same http(s) uri as our list,
160161
// unless we are explicitly requested.
161-
if (uriList.entries.length === 1 && !context?.only?.contains(ResourcePasteOrDropProvider.kind)) {
162+
if (
163+
uriList.entries.length === 1
164+
&& (uriList.entries[0].uri.scheme === Schemes.http || uriList.entries[0].uri.scheme === Schemes.https)
165+
&& !context?.only?.contains(ResourcePasteOrDropProvider.kind)
166+
) {
162167
const text = await dataTransfer.get(Mime.textPlain)?.asString();
163168
if (token.isCancellationRequested) {
164169
return;

0 commit comments

Comments
 (0)