Skip to content

Commit

Permalink
Switch to the new and beautiful VS Dev Shell icons (#17706)
Browse files Browse the repository at this point in the history
We got some new icons for Developer Command Prompt and Developer
PowerShell from our friends over on Visual Studio!

This pull request includes them in the package, and fixes up the VS
dynamic profiles to reset any icons that matched the old paths.

This may be a minor breaking change for user settings, but we're making
the assumption that if they didn't change their VS profile icons from
the defaults, they probably want to follow us to the new defaults.

To prevent anything like this from happening again, we're going to stop
serializing icons for stub profiles.

I've also included a VS version of the PowerShell "black" icon which is
currently unused, but can be used in the future for PS7+-based VS Dev
Shell.

Closes #17627
  • Loading branch information
DHowett authored Aug 13, 2024
1 parent 0fd8dc5 commit 06c07ab
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 22 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
#include "SshHostGenerator.h"
#endif

// userDefault.h is like the above, but with a default template for the user's settings.json.
#include <LegacyProfileGeneratorNamespaces.h>

#include "ApplicationState.h"
#include "DefaultTerminal.h"
#include "FileUtils.h"
Expand Down Expand Up @@ -465,6 +462,11 @@ bool SettingsLoader::FixupUserSettings()
CommandlinePatch{ DEFAULT_WINDOWS_POWERSHELL_GUID, L"powershell.exe", L"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" },
};

static constexpr std::array iconsToClearFromVisualStudioProfiles{
std::wstring_view{ L"ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png" },
std::wstring_view{ L"ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png" },
};

auto fixedUp = userSettings.fixupsAppliedDuringLoad;
fixedUp = userSettings.globals->FixupsAppliedDuringLoad() || fixedUp;

Expand All @@ -473,28 +475,39 @@ bool SettingsLoader::FixupUserSettings()
{
fixedUp = RemapColorSchemeForProfile(profile) || fixedUp;

if (!profile->HasCommandline())
if (profile->HasCommandline())
{
continue;
for (const auto& patch : commandlinePatches)
{
if (profile->Guid() == patch.guid && til::equals_insensitive_ascii(profile->Commandline(), patch.before))
{
profile->ClearCommandline();

// GH#12842:
// With the commandline field on the user profile gone, it's actually unknown what
// commandline it'll inherit, since a user profile can have multiple parents. We have to
// make sure we restore the correct commandline in case we don't inherit the expected one.
if (profile->Commandline() != patch.after)
{
profile->Commandline(winrt::hstring{ patch.after });
}

fixedUp = true;
break;
}
}
}

for (const auto& patch : commandlinePatches)
if (profile->HasIcon() && profile->HasSource() && profile->Source() == VisualStudioGenerator::Namespace)
{
if (profile->Guid() == patch.guid && til::equals_insensitive_ascii(profile->Commandline(), patch.before))
for (auto&& icon : iconsToClearFromVisualStudioProfiles)
{
profile->ClearCommandline();

// GH#12842:
// With the commandline field on the user profile gone, it's actually unknown what
// commandline it'll inherit, since a user profile can have multiple parents. We have to
// make sure we restore the correct commandline in case we don't inherit the expected one.
if (profile->Commandline() != patch.after)
if (profile->Icon() == icon)
{
profile->Commandline(winrt::hstring{ patch.after });
profile->ClearIcon();
fixedUp = true;
break;
}

fixedUp = true;
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsModel/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ Json::Value Profile::ToJson() const
// Recall: Icon isn't actually a setting in the MTSM_PROFILE_SETTINGS. We
// defined it manually in Profile, so make sure we only serialize the Icon
// if the user actually changed it here.
JsonUtils::SetValueForKey(json, IconKey, (writeBasicSettings && HasIcon()) ? Icon() : _Icon);
JsonUtils::SetValueForKey(json, IconKey, _Icon);

// PermissiveStringConverter is unnecessary for serialization
JsonUtils::SetValueForKey(json, PaddingKey, _Padding);
Expand Down
4 changes: 3 additions & 1 deletion src/cascadia/TerminalSettingsModel/VisualStudioGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

using namespace winrt::Microsoft::Terminal::Settings::Model;

std::wstring_view VisualStudioGenerator::Namespace{ L"Windows.Terminal.VisualStudio" };

std::wstring_view VisualStudioGenerator::GetNamespace() const noexcept
{
return std::wstring_view{ L"Windows.Terminal.VisualStudio" };
return Namespace;
}

void VisualStudioGenerator::GenerateProfiles(std::vector<winrt::com_ptr<implementation::Profile>>& profiles) const
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/VisualStudioGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model
class VisualStudioGenerator : public IDynamicProfileGenerator
{
public:
static std::wstring_view Namespace;
std::wstring_view GetNamespace() const noexcept override;
void GenerateProfiles(std::vector<winrt::com_ptr<implementation::Profile>>& profiles) const override;

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsModel/VsDevCmdGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model

std::wstring GetProfileIconPath() const
{
return L"ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png";
return L"ms-appx:///ProfileIcons/vs-cmd.png";
}

std::wstring GetProfileName(const VsSetupConfiguration::VsSetupInstance& instance) const;
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsModel/VsDevShellGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model

std::wstring GetProfileIconPath() const
{
return L"ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png";
return L"ms-appx:///ProfileIcons/vs-powershell.png";
}

std::wstring GetProfileName(const VsSetupConfiguration::VsSetupInstance& instance) const;
Expand Down

0 comments on commit 06c07ab

Please sign in to comment.