mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
[cmdpal] Fix winget extension crash issue (#38074)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request I don't know why defaultInstalledVersion becomes null. But, at least we need to fix it... Test case: vscode.  Closes https://github.com/zadjii-msft/PowerToys/issues/572 Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
This commit is contained in:
@@ -32,8 +32,11 @@ public partial class InstallPackageListItem : ListItem
|
|||||||
_package = package;
|
_package = package;
|
||||||
|
|
||||||
PackageVersionInfo version = _package.DefaultInstallVersion;
|
PackageVersionInfo version = _package.DefaultInstallVersion;
|
||||||
string versionText = version.Version;
|
var versionTagText = "Unknown";
|
||||||
string versionTagText = versionText == "Unknown" && version.PackageCatalog.Info.Id == "StoreEdgeFD" ? "msstore" : versionText;
|
if (version != null)
|
||||||
|
{
|
||||||
|
versionTagText = version.Version == "Unknown" && version.PackageCatalog.Info.Id == "StoreEdgeFD" ? "msstore" : version.Version;
|
||||||
|
}
|
||||||
|
|
||||||
Title = _package.Name;
|
Title = _package.Name;
|
||||||
Subtitle = _package.Id;
|
Subtitle = _package.Id;
|
||||||
@@ -49,8 +52,8 @@ public partial class InstallPackageListItem : ListItem
|
|||||||
CatalogPackageMetadata? metadata = version?.GetCatalogPackageMetadata();
|
CatalogPackageMetadata? metadata = version?.GetCatalogPackageMetadata();
|
||||||
if (metadata != null)
|
if (metadata != null)
|
||||||
{
|
{
|
||||||
string description = string.IsNullOrEmpty(metadata.Description) ? metadata.ShortDescription : metadata.Description;
|
var description = string.IsNullOrEmpty(metadata.Description) ? metadata.ShortDescription : metadata.Description;
|
||||||
string detailsBody = $"""
|
var detailsBody = $"""
|
||||||
|
|
||||||
{description}
|
{description}
|
||||||
""";
|
""";
|
||||||
@@ -102,8 +105,8 @@ public partial class InstallPackageListItem : ListItem
|
|||||||
UriCreationOptions options = default;
|
UriCreationOptions options = default;
|
||||||
foreach (KeyValuePair<string, (string, string)> kv in simpleData)
|
foreach (KeyValuePair<string, (string, string)> kv in simpleData)
|
||||||
{
|
{
|
||||||
string text = string.IsNullOrEmpty(kv.Value.Item1) ? kv.Value.Item2 : kv.Value.Item1;
|
var text = string.IsNullOrEmpty(kv.Value.Item1) ? kv.Value.Item2 : kv.Value.Item1;
|
||||||
string target = kv.Value.Item2;
|
var target = kv.Value.Item2;
|
||||||
if (!string.IsNullOrEmpty(text))
|
if (!string.IsNullOrEmpty(text))
|
||||||
{
|
{
|
||||||
Uri? uri = null;
|
Uri? uri = null;
|
||||||
@@ -153,7 +156,7 @@ public partial class InstallPackageListItem : ListItem
|
|||||||
if (WinGetStatics.AppSearchCallback != null)
|
if (WinGetStatics.AppSearchCallback != null)
|
||||||
{
|
{
|
||||||
Func<string, ICommandItem?> callback = WinGetStatics.AppSearchCallback;
|
Func<string, ICommandItem?> callback = WinGetStatics.AppSearchCallback;
|
||||||
ICommandItem? installedApp = callback(_package.DefaultInstallVersion.DisplayName);
|
ICommandItem? installedApp = callback(_package.DefaultInstallVersion == null ? _package.Name : _package.DefaultInstallVersion.DisplayName);
|
||||||
if (installedApp != null)
|
if (installedApp != null)
|
||||||
{
|
{
|
||||||
this.Command = installedApp.Command;
|
this.Command = installedApp.Command;
|
||||||
|
|||||||
Reference in New Issue
Block a user