Skip to content

Commit

Permalink
Limit drop bail out to just http(s) uris (#209241)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mjbvz authored Apr 1, 2024
1 parent d994aed commit f776fed
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f776fed

Please sign in to comment.