Repository: microsoft/PowerToys
File: src/modules/cmdNotFound/CmdNotFound/WinGetCommandNotFoundFeedbackPredictor.cs (C#)

Code before:

                    // Build list of suggestions
                    _candidates = new List<string>();
                    foreach (var pkg in pkgList)
                    {
                        _candidates.Add(string.Format(CultureInfo.InvariantCulture, "winget install --id {0}", pkg.Members["Id"].Value.ToString()));
                    }

                    // Build footer message
                    var footerMessage = tooManySuggestions ?
                        string.Format(CultureInfo.InvariantCulture, "Additional results can be found using \"winget search --{0} {1}\"", packageMatchFilterField, target) :
                        null;

                    PowerToysTelemetry.Log.WriteEvent(new Telemetry.CmdNotFoundFeedbackProvidedEvent());

                    return new FeedbackItem(
                        "Try installing this package using winget:",
                        _candidates,
                        footerMessage,
                        FeedbackDisplayLayout.Portrait);
                }
                catch (Exception ex)
                {
                    Logger.LogError("GetFeedback failed to execute", ex);

                    return new FeedbackItem("Command Not Found execution failed.", new List<string>(), FeedbackDisplayLayout.Portrait);
                }
            }

            return null;
        }

        private Collection<PSObject> FindPackages(string query, ref bool tooManySuggestions, ref string packageMatchFilterField)
        {
            if (!_warmedUp)
            {
                return new Collection<PSObject>();
            }

            var ps = _pool.Get();
            try
            {
                var common = new Hashtable()
                {
                    ["Source"] = "winget",
                };

                // 1) Search by command
                var pkgList = ps.AddCommand("Find-WinGetPackage")
                    .AddParameter("Command", query)
                    .AddParameter("MatchOption", "StartsWithCaseInsensitive")

Review comment (bug):
```suggestion
                    return new FeedbackItem("PowerToys Command Not Found execution failed. This is a known issue if PowerShell 7 is installed from the Store/MSIX. If that isn't your case, please report an issue.", new List<string>(), FeedbackDisplayLayout.Portrait);
```

Code after:

                    // Build list of suggestions
                    _candidates = new List<string>();
                    foreach (var pkg in pkgList)
                    {
                        _candidates.Add(string.Format(CultureInfo.InvariantCulture, "winget install --id {0}", pkg.Members["Id"].Value.ToString()));
                    }

                    // Build footer message
                    var footerMessage = tooManySuggestions ?
                        string.Format(CultureInfo.InvariantCulture, "Additional results can be found using \"winget search --{0} {1}\"", packageMatchFilterField, target) :
                        null;

                    PowerToysTelemetry.Log.WriteEvent(new Telemetry.CmdNotFoundFeedbackProvidedEvent());

                    return new FeedbackItem(
                        "Try installing this package using winget:",
                        _candidates,
                        footerMessage,
                        FeedbackDisplayLayout.Portrait);
                }
                catch (Exception ex)
                {
                    Logger.LogError("GetFeedback failed to execute", ex);
                    return new FeedbackItem($"Failed to execute PowerToys Command Not Found.{Environment.NewLine}This is a known issue if PowerShell 7 is installed from the Store or MSIX. If that isn't your case, please report an issue.", new List<string>(), FeedbackDisplayLayout.Portrait);
                }
            }

            return null;
        }

        private Collection<PSObject> FindPackages(string query, ref bool tooManySuggestions, ref string packageMatchFilterField)
        {
            if (!_warmedUp)
            {
                return new Collection<PSObject>();
            }

            var ps = _pool.Get();
            try
            {
                var common = new Hashtable()
                {
                    ["Source"] = "winget",
                };

                // 1) Search by command
                var pkgList = ps.AddCommand("Find-WinGetPackage")
                    .AddParameter("Command", query)
                    .AddParameter("MatchOption", "StartsWithCaseInsensitive")
                    .AddParameters(common)