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

Make sure to copy connectionType for the azure shell #12147

Merged
1 commit merged into from
Jan 12, 2022
Merged
Changes from all commits
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
8 changes: 7 additions & 1 deletion src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,13 @@ Model::Profile CascadiaSettings::DuplicateProfile(const Model::Profile& source)
duplicated->UnfocusedAppearance(*unfocusedAppearance);
}

if (source.HasConnectionType())
// GH#12120: Check if the connection type isn't just the default value. If
// it is, then we should copy it. The only case this applies right now is
// for the Azure Cloud Shell, which is the only thing that has a non-{}
// guid. The user's version of this profile won't have connectionType set,
// because it inherits the setting from the parent. If we fail to copy it
// here, they won't actually get a Azure shell profile.
if (source.ConnectionType() != winrt::guid{})
{
duplicated->ConnectionType(source.ConnectionType());
}
Comment on lines +354 to 357
Copy link
Member

Choose a reason for hiding this comment

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

In Go you have this idiom where you write:

if foo := bar(); foo != 123 {
    baz(foo);
}

You can write the same in C++:

 if (const auto type = source.ConnectionType(); type != winrt::guid{})
{
    duplicated->ConnectionType(type);
}

I personally find this idiom quite fitting for such situations.

Copy link
Member

Choose a reason for hiding this comment

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

indeed!

Expand Down