[PT Run][Registry] handle invalid base keys (#13284)

This commit is contained in:
Davide Giacometti
2021-09-20 12:35:39 +02:00
committed by GitHub
parent 2c44cc9cd2
commit c6a24b3907

View File

@@ -86,12 +86,8 @@ namespace Microsoft.PowerToys.Run.Plugin.Registry
// no base key found
return ResultHelper.GetResultList(RegistryHelper.GetAllBaseKeys(), _defaultIconPath);
}
else if (baseKeyList.Count() > 1)
else if (baseKeyList.Count() == 1)
{
// more than one base key was found -> show results
return ResultHelper.GetResultList(baseKeyList.Select(found => new RegistryEntry(found)), _defaultIconPath);
}
// only one base key was found -> start search for the sub-key
var list = RegistryHelper.SearchForSubKey(baseKeyList.First(), subKey);
@@ -104,6 +100,14 @@ namespace Microsoft.PowerToys.Run.Plugin.Registry
return ResultHelper.GetResultList(list, _defaultIconPath);
}
else if (baseKeyList.Count() > 1)
{
// more than one base key was found -> show results
return ResultHelper.GetResultList(baseKeyList.Select(found => new RegistryEntry(found)), _defaultIconPath);
}
return new List<Result>();
}
/// <summary>
/// Return a list context menu entries for a given <see cref="Result"/> (shown at the right side of the result)