Skip to content

Commit

Permalink
polish, part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Aug 17, 2020
1 parent efe126f commit 17648c7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/AzureCloudShellGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ std::vector<Profile> AzureCloudShellGenerator::GenerateProfiles()
azureCloudShellProfile.ColorSchemeName({ L"Vintage" });
azureCloudShellProfile.AcrylicOpacity(0.6);
azureCloudShellProfile.UseAcrylic(true);
azureCloudShellProfile.ConnectionType({ AzureConnectionType });
azureCloudShellProfile.ConnectionType(winrt::guid(AzureConnectionType));
profiles.emplace_back(azureCloudShellProfile);
}

Expand Down
18 changes: 9 additions & 9 deletions src/cascadia/TerminalApp/CascadiaSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const Profile CascadiaSettings::FindProfile(GUID profileGuid) const noexcept
// - <none>
// Return Value:
// - an iterable collection of all of our Profiles.
gsl::span<const winrt::TerminalApp::Profile> CascadiaSettings::GetProfiles() const noexcept
gsl::span<const Profile> CascadiaSettings::GetProfiles() const noexcept
{
return { &_profiles[0], _profiles.size() };
}
Expand Down Expand Up @@ -244,7 +244,7 @@ void CascadiaSettings::_ResolveDefaultProfile()
// warnings if we failed to find the default.
void CascadiaSettings::_ValidateDefaultProfileExists()
{
const winrt::guid defaultProfileGuid = GlobalSettings().DefaultProfile();
const auto defaultProfileGuid = winrt::guid(GlobalSettings().DefaultProfile());
const bool nullDefaultProfile = defaultProfileGuid == winrt::guid{};
bool defaultProfileNotInProfiles = true;
for (const auto& profile : _profiles)
Expand All @@ -263,7 +263,7 @@ void CascadiaSettings::_ValidateDefaultProfileExists()

// _temporarily_ set the default profile to the first profile. Because
// we're adding a warning, this settings change won't be re-serialized.
GlobalSettings().DefaultProfile(_profiles[0].Guid().Value());
GlobalSettings().DefaultProfile(GUID(_profiles[0].Guid().Value()));
}
}

Expand All @@ -279,7 +279,7 @@ void CascadiaSettings::_ValidateNoDuplicateProfiles()

std::vector<size_t> indicesToDelete;

std::set<GUID> uniqueGuids;
std::set<winrt::guid> uniqueGuids;

// Try collecting all the unique guids. If we ever encounter a guid that's
// already in the set, then we need to delete that profile.
Expand Down Expand Up @@ -316,8 +316,8 @@ void CascadiaSettings::_ValidateNoDuplicateProfiles()
// - <none>
void CascadiaSettings::_ReorderProfilesToMatchUserSettingsOrder()
{
std::set<GUID> uniqueGuids;
std::deque<GUID> guidOrder;
std::set<winrt::guid> uniqueGuids;
std::deque<winrt::guid> guidOrder;

auto collectGuids = [&](const auto& json) {
for (auto profileJson : _GetProfilesJsonObject(json))
Expand All @@ -338,7 +338,7 @@ void CascadiaSettings::_ReorderProfilesToMatchUserSettingsOrder()

// Push all the defaultSettings profiles' GUIDS into the set
collectGuids(_defaultSettings);
std::equal_to<GUID> equals;
std::equal_to<winrt::guid> equals;
// Re-order the list of _profiles to match that ordering
// for (gIndex=0 -> uniqueGuids.size)
// pIndex = the pIndex of the profile with guid==guids[gIndex]
Expand Down Expand Up @@ -529,7 +529,7 @@ std::tuple<GUID, TerminalSettings> CascadiaSettings::BuildSettings(const NewTerm
// Arguments:
// - profileGuid: The GUID of a profile to use to create a settings object for.
// Return Value:
// - the GUID of the created profile, and a fully initialized TerminalSettings object
// - a fully initialized TerminalSettings object
TerminalSettings CascadiaSettings::BuildSettings(GUID profileGuid) const
{
const auto profile = FindProfile(profileGuid);
Expand Down Expand Up @@ -607,7 +607,7 @@ try
// lookup a profile. Instead, try using the string to look the
// Profile up by name.
const auto profileIterator{ std::find_if(_profiles.cbegin(), _profiles.cend(), [&](auto&& profile) {
return profile.Name() == name;
return profile.Name().c_str() == name;
}) };

if (profileIterator != _profiles.cend())
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ bool CascadiaSettings::_AppendDynamicProfilesToUserSettings()

for (const auto& profile : _profiles)
{
if (profile.Guid() != nullptr)
if (profile.Guid() == nullptr)
{
// If the profile doesn't have a guid, it's a name-only profile.
// During validation, we'll generate a GUID for the profile, but
Expand Down
9 changes: 4 additions & 5 deletions src/cascadia/TerminalApp/DefaultProfileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ static constexpr std::wstring_view PACKAGED_PROFILE_ICON_EXTENSION{ L".png" };
// - A Profile, ready to be filled in
winrt::TerminalApp::Profile CreateDefaultProfile(const std::wstring_view name)
{
const auto profileGuid{ Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID,
const winrt::guid profileGuid{ Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID,
gsl::as_bytes(gsl::make_span(name))) };
//auto newProfile = winrt::make<winrt::TerminalApp::Profile>(profileGuid);
winrt::TerminalApp::Profile newProfile;
newProfile.Guid({ profileGuid });

winrt::TerminalApp::Profile newProfile{profileGuid};
//auto newProfile = winrt::make<winrt::TerminalApp::Profile>();
newProfile.Guid(profileGuid);
newProfile.Name(name);

std::wstring iconPath{ PACKAGED_PROFILE_ICON_PATH };
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/IDynamicProfileGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Author(s):
--*/

#pragma once
#include "Profile.g.h"
#include "Profile.h"

namespace TerminalApp
{
Expand Down
14 changes: 6 additions & 8 deletions src/cascadia/TerminalApp/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ void Profile::LayerJson(const Json::Value& json)
// - this profile's icon path, if one is set. Otherwise returns the empty string.
winrt::hstring Profile::GetExpandedIconPath() const
{
if (!_Icon.empty())
if (_Icon.empty())
{
return { L"" };
}
winrt::hstring envExpandedPath{ wil::ExpandEnvironmentStringsW<std::wstring>(_Icon.data()) };
winrt::hstring envExpandedPath{ wil::ExpandEnvironmentStringsW<std::wstring>(_Icon.c_str()) };
return envExpandedPath;
}

Expand All @@ -398,14 +398,12 @@ winrt::hstring Profile::GetExpandedIconPath() const
// - This profile's expanded background image path / the empty string.
winrt::hstring Profile::GetExpandedBackgroundImagePath() const
{
winrt::hstring result{};

if (!_BackgroundImage.empty())
if (_BackgroundImage.empty())
{
result = wil::ExpandEnvironmentStringsW<std::wstring>(_BackgroundImage.data());
return { L"" };
}

return result;
winrt::hstring envExpandedPath{ wil::ExpandEnvironmentStringsW<std::wstring>(_BackgroundImage.c_str()) };
return envExpandedPath;
}

// Method Description:
Expand Down
8 changes: 4 additions & 4 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,13 @@ namespace winrt::TerminalApp::implementation
GUID connectionType{ 0 };
GUID sessionGuid{ 0 };

if (profile.ConnectionType())
if (profile.ConnectionType() != nullptr)
{
connectionType = profile.ConnectionType().Value();
}

if (profile.ConnectionType() &&
profile.ConnectionType().Value() == winrt::guid{AzureConnectionType} &&
if (profile.ConnectionType() != nullptr &&
profile.ConnectionType().Value() == winrt::guid{ AzureConnectionType } &&
TerminalConnection::AzureConnection::IsAzureConnectionAvailable())
{
// TODO GH#4661: Replace this with directly using the AzCon when our VT is better
Expand Down Expand Up @@ -1995,7 +1995,7 @@ namespace winrt::TerminalApp::implementation
auto profiles = _settings->GetProfiles();
for (auto& profile : profiles)
{
const GUID profileGuid = GUID(profile.Guid().Value()) ;
const GUID profileGuid = GUID(profile.Guid().Value());

try
{
Expand Down

0 comments on commit 17648c7

Please sign in to comment.