Skip to content

Commit f4bffcf

Browse files
committed
wsl: skip distributions that indicate they are "Modern" (#18183)
(cherry picked from commit 00ff803) Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgUu4sc Service-Version: 1.21
1 parent ef89e13 commit f4bffcf

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/cascadia/TerminalSettingsModel/WslDistroGenerator.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static constexpr std::wstring_view RancherDistributionPrefix{ L"rancher-desktop"
1919
// ⌞ DistributionName: {the name}
2020
static constexpr wchar_t RegKeyLxss[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Lxss";
2121
static constexpr wchar_t RegKeyDistroName[] = L"DistributionName";
22+
static constexpr wchar_t RegKeyModern[] = L"Modern";
2223

2324
using namespace ::Microsoft::Terminal::Settings::Model;
2425
using namespace winrt::Microsoft::Terminal::Settings::Model;
@@ -188,6 +189,12 @@ static bool getWslNames(const wil::unique_hkey& wslRootKey,
188189
continue;
189190
}
190191

192+
const auto modernValue{ wil::reg::try_get_value<uint32_t>(distroKey.get(), RegKeyModern) };
193+
if (modernValue.value_or(0u) == 1u)
194+
{
195+
continue;
196+
}
197+
191198
std::wstring buffer;
192199
auto result = wil::AdaptFixedSizeToAllocatedResult<std::wstring, 256>(buffer, [&](PWSTR value, size_t valueLength, size_t* valueLengthNeededWithNull) -> HRESULT {
193200
auto length = gsl::narrow<DWORD>(valueLength * sizeof(wchar_t));

src/cascadia/TerminalSettingsModel/pch.h

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#endif
2525

2626
#include <wil/cppwinrt.h>
27+
#include <wil/registry.h>
2728

2829
#include <winrt/Windows.ApplicationModel.AppExtensions.h>
2930
#include <winrt/Windows.ApplicationModel.h>

0 commit comments

Comments
 (0)