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

implement drag&drop path in '+' button (#10073) #10160

Merged
2 commits merged into from
Jul 20, 2021
Merged

implement drag&drop path in '+' button (#10073) #10160

2 commits merged into from
Jul 20, 2021

Conversation

Daniel599
Copy link
Contributor

Summary of the Pull Request

This PR implements the ability to drop directories/files on the '+' button which in turn will open the tab/pane/window in the given starting path.
In order to do this, I refactored the click's lambda into a method and re-used it
Sadly I wasn't able to add note about the alt/shift feature (any ideas how to do this?)
Also most of the code is "look-a-like" from other places within the project, as I don't have much experience in windows development.

References

implements #10073

PR Checklist

  • Closes Drag folder/file to '+' button to open new tab in directory #10073
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
    ** tests were done manually both of the old feature (alt/shift+click) on the '+' and on the profiles
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
    ** no idea what to add there, if any.
  • Schema updated.
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

tested manually.

@ghost ghost added Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels May 23, 2021
@j4james
Copy link
Collaborator

j4james commented May 23, 2021

FYI, there's a runformat.cmd script in the tools directory that will apply the correct code formatting to your source, so it'll pass the Code Health check when you push your changes.

@Daniel599
Copy link
Contributor Author

FYI, there's a runformat.cmd script in the tools directory that will apply the correct code formatting to your source, so it'll pass the Code Health check when you push your changes.

Thanks for the tip, I totally forgot about that script. Hope it will pass now.


std::wstring pathText = path.wstring();

// Handle edge case of "C:\\", seems like the "StartingDirectory" doesn't like path which ends with '\'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait what? My experience with StartingDirectory tells me this can't be true ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This edge case happens when you press shift and drop the C: drive on it, you get the following error:

[error 0x8007010b when launching `cmd.exe']
Could not access starting directory "C:\WINDOWS\SysWOW64""

D: drive

[error 0x8007010b when launching `cmd.exe']
Could not access starting directory "D:""

While trying to debug the value of pathText I notice normal folders don't end with \ while C & D drives do.
removing that \ solved the problem...maybe it solved it by avoiding it?
can you please help me understand why it happens?
note that pressing shift is critical since normal drop works just fine.
If you think it should work without this if will trying to debug it further.

if (items.Size() == 1)
{
std::filesystem::path path(items.GetAt(0).Path().c_str());
if (!std::filesystem::is_directory(path))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wonder how well std::filesystem::is_directory handles UNC paths.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tested it with \\HOST\folder and \\HOST\folder\file.txt, std::filesystem::is_directory handles it just fine.
Sadly darg & drop this UNC path only works with windows powershell.
Command Prompt gives the following error:

'\\HOST\folder'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
Microsoft Windows [Version 10.0.19042.985]
(c) Microsoft Corporation. All rights reserved.

C:\Windows>

while ubuntu just default to the home folder.

@skyline75489
Copy link
Collaborator

@Daniel599 Thanks for the contribution! The core developers of the project are probably busy preparing for Build 2021. So it might take a while for them to review this.

@Daniel599
Copy link
Contributor Author

@skyline75489 any update regarding this PR?

@skyline75489
Copy link
Collaborator

@Daniel599 sry about not responding. The engineer who is more eligible to review this is currently out of the office for vacation and won’t have the time until next month. There’s only limited engineering power at the moment. So it might take a while for people to get to this PR.

@skyline75489
Copy link
Collaborator

Hi @Daniel599 sorry for not responding for a long time.😅

The team is currently preparing for 1.10 release, and this PR is likely to miss the 1.10 train. Wonder if @zadjii-msft has interest to take a look and probably ship this in 1.11.

@zadjii-msft zadjii-msft added the Needs-Discussion Something that requires a team discussion before we can proceed label Jul 15, 2021
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

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

I'm good with this. Apologies for the delay. We had discussed this at a team meeting and then I think things happened to the major people at that meeting. Like @zadjii-msft going on paternity leave, me visiting my family and then having my son get sick (and then getting sick), and a few other kerfluffles like prepping the 1.10 release.

I'm not the biggest authority on the team at XAML or the Terminal UI... but the code looks fair enough to me and I like the de-duplication of the tab/window opening stuff. So I'll give you one check.

// - Bound in Drag&Drop of the Xaml editor to the [+] button.
// Arguments:
// <unused>
void TabRowControl::OnNewTabButtonDrop(IInspectable const&, winrt::Windows::UI::Xaml::DragEventArgs const&)
Copy link
Member

Choose a reason for hiding this comment

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

Do we have to make and bind this if nothing is going to happen? Is this some XAML trickery?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so, I did copy-cat of the other Drag&Drop stuff.
I`ll try to remove it and see what happens

Copy link
Member

Choose a reason for hiding this comment

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

Whichever way it works, I'm fine with it. It was just an interesting curiosity to me.

@Daniel599
Copy link
Contributor Author

I'm good with this. Apologies for the delay. We had discussed this at a team meeting and then I think things happened to the major people at that meeting. Like @zadjii-msft going on paternity leave, me visiting my family and then having my son get sick (and then getting sick), and a few other kerfluffles like prepping the 1.10 release.

I'm not the biggest authority on the team at XAML or the Terminal UI... but the code looks fair enough to me and I like the de-duplication of the tab/window opening stuff. So I'll give you one check.

Thank you for the update, hope you are feeling well now.
I did rebase and now the checks don't pass, any idea why? seems like "unit tests" step but its output is too huge to understand.

@zadjii-msft zadjii-msft removed the Needs-Discussion Something that requires a team discussion before we can proceed label Jul 19, 2021
@zadjii-msft
Copy link
Member

sorry for the delay, I'm checking out the code locally right now to give it a review. Probably won't get a full build before EOD but hopefully will early tomorrow.

@skyline75489
Copy link
Collaborator

Ah again the ApiRoutinesTests::ApiGetConsoleOriginalTitleA failure. @Daniel599 it's not your fault. There's a PR to fix this.

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.

Okay, sorry for the delay reviewing this. The code is nice and straightforward, and I like that it stealthily also works with alt+drag&drop.

I am seeing weird edge cases with C:\, but you know what, I'm just gonna merge this for now and file some follow ups.

Thanks for doing this!

@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jul 20, 2021
@ghost
Copy link

ghost commented Jul 20, 2021

Hello @zadjii-msft!

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.

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.

@ghost
Copy link

ghost commented Aug 31, 2021

🎉Windows Terminal Preview v1.11.2421.0 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-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drag folder/file to '+' button to open new tab in directory
5 participants