Skip to content

Commit 2befaa1

Browse files
committed
Switch to the new and beautiful VS Dev Shell icons (#17706)
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: 93531229 Service-Version: 1.21
1 parent 83a9baa commit 2befaa1

15 files changed

+38
-22
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp

+31-18
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
#include "SshHostGenerator.h"
1919
#endif
2020

21-
// userDefault.h is like the above, but with a default template for the user's settings.json.
22-
#include <LegacyProfileGeneratorNamespaces.h>
23-
2421
#include "ApplicationState.h"
2522
#include "DefaultTerminal.h"
2623
#include "FileUtils.h"
@@ -460,35 +457,51 @@ bool SettingsLoader::FixupUserSettings()
460457
CommandlinePatch{ DEFAULT_WINDOWS_POWERSHELL_GUID, L"powershell.exe", L"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" },
461458
};
462459

460+
static constexpr std::array iconsToClearFromVisualStudioProfiles{
461+
std::wstring_view{ L"ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png" },
462+
std::wstring_view{ L"ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png" },
463+
};
464+
463465
auto fixedUp = userSettings.fixupsAppliedDuringLoad;
464466

465467
fixedUp = RemapColorSchemeForProfile(userSettings.baseLayerProfile) || fixedUp;
466468
for (const auto& profile : userSettings.profiles)
467469
{
468470
fixedUp = RemapColorSchemeForProfile(profile) || fixedUp;
469471

470-
if (!profile->HasCommandline())
472+
if (profile->HasCommandline())
471473
{
472-
continue;
474+
for (const auto& patch : commandlinePatches)
475+
{
476+
if (profile->Guid() == patch.guid && til::equals_insensitive_ascii(profile->Commandline(), patch.before))
477+
{
478+
profile->ClearCommandline();
479+
480+
// GH#12842:
481+
// With the commandline field on the user profile gone, it's actually unknown what
482+
// commandline it'll inherit, since a user profile can have multiple parents. We have to
483+
// make sure we restore the correct commandline in case we don't inherit the expected one.
484+
if (profile->Commandline() != patch.after)
485+
{
486+
profile->Commandline(winrt::hstring{ patch.after });
487+
}
488+
489+
fixedUp = true;
490+
break;
491+
}
492+
}
473493
}
474494

475-
for (const auto& patch : commandlinePatches)
495+
if (profile->HasIcon() && profile->HasSource() && profile->Source() == VisualStudioGenerator::Namespace)
476496
{
477-
if (profile->Guid() == patch.guid && til::equals_insensitive_ascii(profile->Commandline(), patch.before))
497+
for (auto&& icon : iconsToClearFromVisualStudioProfiles)
478498
{
479-
profile->ClearCommandline();
480-
481-
// GH#12842:
482-
// With the commandline field on the user profile gone, it's actually unknown what
483-
// commandline it'll inherit, since a user profile can have multiple parents. We have to
484-
// make sure we restore the correct commandline in case we don't inherit the expected one.
485-
if (profile->Commandline() != patch.after)
499+
if (profile->Icon() == icon)
486500
{
487-
profile->Commandline(winrt::hstring{ patch.after });
501+
profile->ClearIcon();
502+
fixedUp = true;
503+
break;
488504
}
489-
490-
fixedUp = true;
491-
break;
492505
}
493506
}
494507
}

src/cascadia/TerminalSettingsModel/Profile.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ Json::Value Profile::ToJson() const
329329
// Recall: Icon isn't actually a setting in the MTSM_PROFILE_SETTINGS. We
330330
// defined it manually in Profile, so make sure we only serialize the Icon
331331
// if the user actually changed it here.
332-
JsonUtils::SetValueForKey(json, IconKey, (writeBasicSettings && HasIcon()) ? Icon() : _Icon);
332+
JsonUtils::SetValueForKey(json, IconKey, _Icon);
333333

334334
// PermissiveStringConverter is unnecessary for serialization
335335
JsonUtils::SetValueForKey(json, PaddingKey, _Padding);

src/cascadia/TerminalSettingsModel/VisualStudioGenerator.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

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

12+
std::wstring_view VisualStudioGenerator::Namespace{ L"Windows.Terminal.VisualStudio" };
13+
1214
std::wstring_view VisualStudioGenerator::GetNamespace() const noexcept
1315
{
14-
return std::wstring_view{ L"Windows.Terminal.VisualStudio" };
16+
return Namespace;
1517
}
1618

1719
void VisualStudioGenerator::GenerateProfiles(std::vector<winrt::com_ptr<implementation::Profile>>& profiles) const

src/cascadia/TerminalSettingsModel/VisualStudioGenerator.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model
2626
class VisualStudioGenerator : public IDynamicProfileGenerator
2727
{
2828
public:
29+
static std::wstring_view Namespace;
2930
std::wstring_view GetNamespace() const noexcept override;
3031
void GenerateProfiles(std::vector<winrt::com_ptr<implementation::Profile>>& profiles) const override;
3132

src/cascadia/TerminalSettingsModel/VsDevCmdGenerator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model
4141

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

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

src/cascadia/TerminalSettingsModel/VsDevShellGenerator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model
3838

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

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

0 commit comments

Comments
 (0)