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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ NewTerminalArgs Pane::GetTerminalArgsForPane() const
auto controlSettings = _control.Settings().as<TerminalSettings>();

args.Profile(controlSettings.ProfileName());
args.StartingDirectory(controlSettings.StartingDirectory());
// If we know the user's working directory use it instead of the profile.
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.

else
{
args.StartingDirectory(controlSettings.StartingDirectory());
}
args.TabTitle(controlSettings.StartingTitle());
args.Commandline(controlSettings.Commandline());
args.SuppressApplicationTitle(controlSettings.SuppressApplicationTitle());
Expand Down