Skip to content
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

Fix missing paths when items dropped from archive #14648

Merged
8 commits merged into from
Jan 11, 2023

Conversation

jiejasonliu
Copy link
Contributor

@jiejasonliu jiejasonliu commented Jan 7, 2023

Grab all paths from DROPFILES struct provided in drag event data

GetStorageItemsAsync() only giving up to 16 items when items are dropped from any archives

  • When this occurs, we should look into FileDrop key for a stream of the DROPFILES struct
  • This struct contains a null-character delimited string of paths which we can just read out

Validation Steps Performed

  • Unit tests pass locally
  • Drag and drop paths work for both archives and non-archives files, folders, shortcuts, etc.

Closes #14628

@ghost ghost added Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. labels Jan 7, 2023
@jiejasonliu
Copy link
Contributor Author

@microsoft-github-policy-service agree

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, I see how this works, but is there any documentation on this? It seems like ~ m a g i c ~ that getting the "FileDrop" out of a DataPackageView just so happens to have the value of a HDROP embedded in the stream. It's just crazy.

Though, https://learn.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.DataTransfer.StandardDataFormats?view=winrt-22621 does list a bunch of other magic strings that seem to return HGLOBALs, so I'm not doubting it, I'd just like to have an official reference to point to.

src/cascadia/TerminalControl/TermControl.cpp Show resolved Hide resolved
@jiejasonliu
Copy link
Contributor Author

I mean, I see how this works, but is there any documentation on this?

I totally get that and I'll try my best to compile all the resources I've used.
Admittedly, I can't give you exact answers since a lot of things are closed source.
It really came down to relying on older references and anticipating backward compatibility was kept.

just so happens to have the value of a HDROP

My initial discovery was looking through the data package's AvailableFormats property.

Upon finding FileDrop, I dug into the .NET reference source and found this line of code where the callee stores it in an HDROP format. So yes, an HDROP embedded directly in the stream!

Then combining these (one) (two) sources, I was able to successfully parse the file paths out.
Technically, you could manually parse them, but the intrinsic DragQueryFile does exactly that for you.

@zadjii-msft zadjii-msft added this to the Terminal v1.17 milestone Jan 10, 2023
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just sprinkled a few const throughout. Thanks!

src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
@carlos-zamora
Copy link
Member

@msftbot merge this in 20 minutes

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 10, 2023
@ghost
Copy link

ghost commented Jan 10, 2023

Hello @carlos-zamora!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Tue, 10 Jan 2023 23:03:31 GMT, which is in 20 minutes

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@carlos-zamora
Copy link
Member

Extracted from PR body:

Attachments

Terminal-14628-before.mp4
Terminal-14628-after.mp4

@DHowett DHowett removed the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 10, 2023
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few style notes, otherwise: Thanks so much for doing this!

src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 11, 2023
@ghost
Copy link

ghost commented Jan 11, 2023

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about -3619 seconds. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@DHowett
Copy link
Member

DHowett commented Jan 11, 2023

I had one last drive-by change, as I'd checked the code out to verify my casts/emplaces worked, to reduce another copy. Opportunistic, not required :)

Marked for automatic merge and servicing to 1.16. Thanks again!

@ghost ghost merged commit b7e537e into microsoft:main Jan 11, 2023
DHowett pushed a commit that referenced this pull request Jan 13, 2023
Grab all paths from `DROPFILES` struct provided in drag event data

`GetStorageItemsAsync()` only giving up to 16 items when items are dropped from any archives
- When this occurs, we should look into `FileDrop` key for a stream of the [`DROPFILES struct`](https://learn.microsoft.com/en-us/windows/win32/shell/clipboard#cf_hdrop)
- This struct contains a null-character delimited string of paths which we can just read out

## Validation Steps Performed
* [X] Unit tests pass locally
* [X] Drag and drop paths work for both archives and non-archives files, folders, shortcuts, etc.

Closes #14628

(cherry picked from commit b7e537e)
Service-Card-Id: 87548939
Service-Version: 1.16
@ghost
Copy link

ghost commented Jan 24, 2023

🎉Windows Terminal v1.16.1023 (10231 and 10232) has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Jan 24, 2023

🎉Windows Terminal Preview v1.17.1023 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-UserInterface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dragging and dropping paths to terminal stops at 16 items
4 participants