Skip to content

Commit

Permalink
wsl: skip distributions that indicate they are "Modern" (#18183)
Browse files Browse the repository at this point in the history
  • Loading branch information
DHowett authored Nov 13, 2024
1 parent 772f546 commit 00ff803
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cascadia/TerminalSettingsModel/WslDistroGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ static constexpr std::wstring_view RancherDistributionPrefix{ L"rancher-desktop"
// ⌞ DistributionName: {the name}
static constexpr wchar_t RegKeyLxss[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Lxss";
static constexpr wchar_t RegKeyDistroName[] = L"DistributionName";
static constexpr wchar_t RegKeyModern[] = L"Modern";

using namespace ::Microsoft::Terminal::Settings::Model;
using namespace winrt::Microsoft::Terminal::Settings::Model;
Expand Down Expand Up @@ -188,6 +189,12 @@ static bool getWslNames(const wil::unique_hkey& wslRootKey,
continue;
}

const auto modernValue{ wil::reg::try_get_value<uint32_t>(distroKey.get(), RegKeyModern) };
if (modernValue.value_or(0u) == 1u)
{
continue;
}

std::wstring buffer;
auto result = wil::AdaptFixedSizeToAllocatedResult<std::wstring, 256>(buffer, [&](PWSTR value, size_t valueLength, size_t* valueLengthNeededWithNull) -> HRESULT {
auto length = gsl::narrow<DWORD>(valueLength * sizeof(wchar_t));
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#endif

#include <wil/cppwinrt.h>
#include <wil/registry.h>

#include <winrt/Windows.ApplicationModel.AppExtensions.h>
#include <winrt/Windows.ApplicationModel.h>
Expand Down

0 comments on commit 00ff803

Please sign in to comment.