mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 00:48:23 -06:00
Update WinGet CNF for exact command matching (#19432)
## Summary of the Pull Request Update the WinGet CNF package search to match that of the updated PowerShell WinGet CNF module. Now, we'll only search for matching commands instead of by name and moniker. ## References and Relevant Issues https://github.com/microsoft/winget-command-not-found/pull/29 ## Validation Steps Performed ✅ In CMD, type "vim" and vim packages are suggested (cherry picked from commit 819987c90e17dbf6301c777d2ec553a7d115db75) Service-Card-Id: PVTI_lADOAF3p4s4BBcTlzgfuACY Service-Version: 1.24
This commit is contained in:
parent
77ee52b872
commit
d35bc4cee6
@ -3216,33 +3216,17 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
|
||||
PackageCatalog catalog = connectResult.PackageCatalog();
|
||||
// clang-format off
|
||||
static constexpr std::array<WinGetSearchParams, 3> searches{ {
|
||||
{ .Field = PackageMatchField::Command, .MatchOption = PackageFieldMatchOption::StartsWithCaseInsensitive },
|
||||
{ .Field = PackageMatchField::Name, .MatchOption = PackageFieldMatchOption::ContainsCaseInsensitive },
|
||||
{ .Field = PackageMatchField::Moniker, .MatchOption = PackageFieldMatchOption::ContainsCaseInsensitive } } };
|
||||
// clang-format on
|
||||
|
||||
PackageMatchFilter filter = WindowsPackageManagerFactory::CreatePackageMatchFilter();
|
||||
filter.Value(query);
|
||||
filter.Field(PackageMatchField::Command);
|
||||
filter.Option(PackageFieldMatchOption::Equals);
|
||||
|
||||
FindPackagesOptions options = WindowsPackageManagerFactory::CreateFindPackagesOptions();
|
||||
options.Filters().Append(filter);
|
||||
options.ResultLimit(20);
|
||||
|
||||
IVectorView<MatchResult> pkgList;
|
||||
for (const auto& search : searches)
|
||||
{
|
||||
filter.Field(search.Field);
|
||||
filter.Option(search.MatchOption);
|
||||
|
||||
const auto result = co_await catalog.FindPackagesAsync(options);
|
||||
pkgList = result.Matches();
|
||||
if (pkgList.Size() > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
const auto result = co_await catalog.FindPackagesAsync(options);
|
||||
const IVectorView<MatchResult> pkgList = result.Matches();
|
||||
co_return pkgList;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user