Skip to content

Commit 71be4ee

Browse files
committed
apply feedback
1 parent 68dc291 commit 71be4ee

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed
Binary file not shown.

src/cascadia/TerminalSettingsModel/CascadiaSettings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
238238
public:
239239
FragmentProfileEntry(winrt::guid profileGuid, hstring json) :
240240
_profileGuid{ profileGuid },
241-
_Json{ json } {}
241+
Json{ json } {}
242242

243243
winrt::guid ProfileGuid() const noexcept { return _profileGuid; }
244-
WINRT_PROPERTY(hstring, Json);
244+
til::property<hstring> Json;
245245

246246
private:
247247
winrt::guid _profileGuid;

src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,21 @@ SettingsLoader::SettingsLoader(const std::string_view& userJSON, const std::stri
179179
// (meaning profiles specified by the application rather by the user).
180180
void SettingsLoader::GenerateProfiles()
181181
{
182-
PowershellCoreProfileGenerator powerShellGenerator{};
183-
_executeGenerator(powerShellGenerator);
182+
{
183+
PowershellCoreProfileGenerator powerShellGenerator{};
184+
_executeGenerator(powerShellGenerator);
185+
186+
const auto isPowerShellInstalled = !powerShellGenerator.GetPowerShellInstances().empty();
187+
if (!isPowerShellInstalled)
188+
{
189+
// Only generate the installer stub profile if PowerShell isn't installed.
190+
PowershellInstallationProfileGenerator pwshInstallationGenerator{};
191+
_executeGenerator(pwshInstallationGenerator);
192+
}
193+
194+
// Regardless of running the installer's generator, we need to do some cleanup still.
195+
_cleanupPowerShellInstaller(isPowerShellInstalled);
196+
}
184197

185198
WslDistroGenerator wslGenerator{};
186199
_executeGenerator(wslGenerator);
@@ -195,11 +208,6 @@ void SettingsLoader::GenerateProfiles()
195208
SshHostGenerator sshGenerator{};
196209
_executeGenerator(sshGenerator);
197210
#endif
198-
199-
PowershellInstallationProfileGenerator pwshInstallationGenerator{};
200-
_executeGenerator(pwshInstallationGenerator);
201-
202-
_cleanupPowerShellInstaller(!powerShellGenerator.GetPowerShellInstances().empty());
203211
}
204212

205213
// Retrieve the "Install Latest PowerShell" profile and...

src/cascadia/TerminalSettingsModel/PowershellInstallationProfileGenerator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <LibraryResources.h>
1010

1111
static constexpr std::wstring_view POWERSHELL_ICON{ L"ms-appx:///ProfileIcons/pwsh.png" };
12-
static constexpr std::wstring_view POWERSHELL_ICON_64{ L"ms-appx:///ProfileIcons/Powershell_black_64.png" };
12+
static constexpr std::wstring_view GENERATOR_POWERSHELL_ICON{ L"ms-appx:///ProfileGeneratorIcons/PowerShell.png" };
1313

1414
namespace winrt::Microsoft::Terminal::Settings::Model
1515
{
@@ -27,13 +27,13 @@ namespace winrt::Microsoft::Terminal::Settings::Model
2727

2828
std::wstring_view PowershellInstallationProfileGenerator::GetIcon() const noexcept
2929
{
30-
return POWERSHELL_ICON_64;
30+
return GENERATOR_POWERSHELL_ICON;
3131
}
3232

3333
void PowershellInstallationProfileGenerator::GenerateProfiles(std::vector<winrt::com_ptr<implementation::Profile>>& profiles)
3434
{
3535
auto profile{ CreateDynamicProfile(RS_(L"PowerShellInstallationProfileName")) };
36-
profile->Commandline(winrt::hstring{ fmt::format(FMT_COMPILE(L"cmd /k winget install --interactive --id Microsoft.PowerShell & echo. & echo {} & exit"), RS_(L"PowerShellInstallationInstallerGuidance")) });
36+
profile->Commandline(winrt::hstring{ fmt::format(FMT_COMPILE(L"cmd /k winget install --interactive --id Microsoft.PowerShell --source winget & echo. & echo {} & exit"), RS_(L"PowerShellInstallationInstallerGuidance")) });
3737
profile->Icon(winrt::hstring{ POWERSHELL_ICON });
3838
profile->CloseOnExit(CloseOnExitMode::Never);
3939

0 commit comments

Comments
 (0)