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

Try to persist the Pane's working directory if we know what it is. #11374

Merged
2 commits merged into from
Oct 4, 2021

Conversation

Rosefield
Copy link
Contributor

Summary of the Pull Request

Try to save the working directory if we know what it is (just copied what was done in duplicating a pane). I overlooked this in my original implementation that always used the settings StartingDirectory.

References

#9800

PR Checklist

  • Closes #xxx
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • 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

Tried setting the working directory using the OSC 9;9 escape and confirmed that the directory saves correctly.

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.

this is a really cool idea, I love it

Comment on lines 132 to 135
if (!_control.WorkingDirectory().empty())
{
args.StartingDirectory(_control.WorkingDirectory());
}
Copy link
Member

Choose a reason for hiding this comment

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

You can prevent the double-COM-call with

Suggested change
if (!_control.WorkingDirectory().empty())
{
args.StartingDirectory(_control.WorkingDirectory());
}
if (const auto path = _control.WorkingDirectory(); !path.empty())
{
args.StartingDirectory(path);
}

I love the syntax... it strongly reminds me of Go.

…put multiple statements into an if, although I dont know if I like it. Seems like this was added in c++17 so thats why I didnt know about it
@lhecker
Copy link
Member

lhecker commented Oct 1, 2021

That commit message made me genuinely laugh aloud. 😄

To be fair in Go their use is a bit more prevalent as the language lacks sum types (just like C++, but their tuples are way more ergonomic, so...).
So you often see tuples being returned of the (T, bool) (aka std::pair<T, bool>) kind and you get code like this:

if value, found := myHashMap[foo]; found {
    ...
}

But I still find it useful in C++, since you never know if a getter is a trivial or - for the lack of better words - a "computing" one and I'm trying to proactively avoid hitting issues with the latter kind. Please feel free to disagree in reviews though. :)

@Rosefield
Copy link
Contributor Author

I was completely ok with the operator bool things since I'm so used to writing if let Some(x) = foo() in rust. Rust recently approved if let chains as a feature so I'll have to adapt to the new landscape regardless. Its all just sugar around scoping anyways 🤷

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

ghost commented Oct 4, 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 ghost merged commit b2fd65c into microsoft:main Oct 4, 2021
@Rosefield Rosefield deleted the bug/persist-working-directory branch October 20, 2021 04:05
@ghost
Copy link

ghost commented Oct 20, 2021

🎉Windows Terminal Preview v1.12.2922.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
AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants