-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot drag/drop file from VS Code to other apps due to invalid data object #91132
Comments
@davkean hi. Thanks for trying this out and for providing feedback. Feel free to experiment with the code here If you can make this work to be able to drop in Visual Studio while still working with our current use cases of dropping between VS Code instances and native explorer / finders then we would be open to accept a PR. fyi @bpasero |
That's fine, but the Window's Shell IDataObject that VS Code is providing says it supports "CF_HDROP". If it indeed does not provide that format, then QueryGetData should be returning DV_E_FORMATETC, so that the drop operation is blocked. |
Not sure how much of this behavior we can control since that is probably just done by Chrome (since VS Code is built on top of Electron that uses Chrome). Anyways just try changing the code at the pointer I provided, not sure if possible to achieve what you would like. Thanks |
Duplicate of #164 Electron does not give us any data to control the contents of the operation as far as I know. |
@bpasero A quick search through the Chromium source, I can find code that pulls CF_HDROP from the clipboard, but can't find the actual implementation of the IDataObject that we're seeing as the target or anything pushing CF_HDROP on the clipboard. It's the one that has a broken QueryGetData. |
There is actually API: https://github.com/electron/electron/blob/7-0-x/docs/api/clipboard.md Related: electron/electron#11838 I am open for help here, be it Electron, Chrome itself or VSCode side if we can improve this. //cc @deepak1556 |
There's two things here;
|
Can confirm this still happens in the latest vscode. |
With #181373, we now set the standard I've confirmed that this works correctly when dropping from VS Code into the Chrome address bar @davkean Does VS handle drops of |
No we don't, but will file a bug to accept it. @mjbvz The intention here is to only support dragging to another app and have it open the file? You are not adding support for copy/move? For copy/move (say to Solution Exporer in Visual Studio or File Explorer in Windows), you should be using CF_HDROP/FileDrop. |
I should state, this particular bug was that VS Code's data object was saying that supported "CF_HDROP/FileDrop" but it didn't actually when it came to pulling the data. |
With this change, drops from VS Code should look like drops from any webpage that sets |
I wish... Eg: I am using VSC and would like to be able to drag a file from the Explorer side bar to say a different application just like i might do from a (MacOs) The drag shouldn't move a file - just allows a file to be handled just like it would be if I was doing it from an OS File Explorer window. At the moment I have to say something like Even if user was required to press CTRL or ALT as part of the DRAG would be better to make it a single step and easier process. |
Version: 1.42.1 (user setup)
Commit: c47d83b
Date: 2020-02-11T14:45:59.656Z
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.18363
Steps to Reproduce:
Drag a file from Explorer tool window and drop it onto:
Visual Studio
Expected: For VS to open the file
Actual: Get stop icon indicating the drag is not supported
Expected: For the file to be copied to the project
Actual: Get an drag icon indicating that a Copy will occur, but after dropping nothing happens --
Outlook
Expected: New Email with file as attachment
Actual : Message Box with Cannot copy the items
Excel
Expected: File to be opened as text
Actual: Just the file name is pasted into cell
Does this issue occur when all extensions are disabled?: Yes
Background
I work on Visual Studio and debugged this from our side, and this is what I've found. We are expecting a format of CF_HDROP and doing the following pseudo code:
QueryGetData is saying "I support this format", yet GetData is returning a HRESULT saying the format we just passed to QueryGetData is invalid. I suspect this is happening similarly in other applications. We have 4 or 5 places we look CF_HDROP and everyone of them fails.
I spent a little bit of time trying to figure out how VS Code produces CF_HDROP but to no avail. Could not find any code that looks like it puts a data object into the clipboard other than text.
The text was updated successfully, but these errors were encountered: