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

(cherry picked from commit 06c07ab)
Service-Card-Id: 93531228
Service-Version: 1.20
  • Loading branch information
DHowett committed Aug 20, 2024
1 parent a8064e7 commit 7e67791
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 19 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 @@ -420,32 +420,48 @@ bool SettingsLoader::FixupUserSettings()
CommandlinePatch{ DEFAULT_WINDOWS_POWERSHELL_GUID, L"powershell.exe", L"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" },
};

auto fixedUp = false;
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 = false

for (const auto& profile : userSettings.profiles)
{
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
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 7e67791

Please sign in to comment.