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

Switch to the new and beautiful VS Dev Shell icons #17706

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
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
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
Loading