Compare commits

..

2 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
466bd0c0a5 Fix: subscribe to ItemsChanged before fetching items to avoid missing early events
Agent-Logs-Url: https://github.com/microsoft/PowerToys/sessions/3f380bd3-a56a-4708-80ef-3e7d534c4f6f

Co-authored-by: MuyuanMS <116717757+MuyuanMS@users.noreply.github.com>
2026-04-29 08:58:21 +00:00
copilot-swe-agent[bot]
8db30b7e46 Initial plan 2026-04-29 08:49:46 +00:00
8 changed files with 8 additions and 83 deletions

View File

@@ -129,8 +129,8 @@ public partial class ContentPageViewModel : PageViewModel, ICommandBarContext
UpdateDetails();
FetchContent();
model.ItemsChanged += Model_ItemsChanged;
FetchContent();
DoOnUiThread(
() =>

View File

@@ -44,9 +44,9 @@ public partial class ContentTreeViewModel(ITreeContent _tree, WeakReference<IPag
UpdateProperty(nameof(Root));
}
FetchContent();
model.PropChanged += Model_PropChanged;
model.ItemsChanged += Model_ItemsChanged;
FetchContent();
}
// Theoretically, we should unify this with the one in CommandPalettePageViewModelFactory

View File

@@ -209,8 +209,8 @@ public sealed partial class DockBandViewModel : ExtensionObjectViewModel
var list = command.Model.Unsafe as IListPage;
if (list is not null)
{
InitializeFromList(list);
list.ItemsChanged += HandleItemsChanged;
InitializeFromList(list);
}
else
{

View File

@@ -957,8 +957,8 @@ public partial class ListViewModel : PageViewModel, IDisposable
Filters?.InitializeProperties();
UpdateProperty(nameof(Filters));
FetchItems(true);
model.ItemsChanged += Model_ItemsChanged;
FetchItems(true);
}
private static IGridPropertiesViewModel? LoadGridPropertiesViewModel(IGridProperties? gridProperties)

View File

@@ -55,18 +55,13 @@ namespace Wox.Infrastructure.Image
return fs.Read(buffer, 0, buffer.Length) == buffer.Length && pngSignature.SequenceEqual(buffer);
}
internal static string GetNormalizedPath(string path)
{
return PathNormalization.NormalizePath(path);
}
public static void Initialize()
{
_hashGenerator = new ImageHashGenerator();
foreach (var icon in new[] { Constant.ErrorIcon, Constant.LightThemedErrorIcon })
{
var uri = new Uri(GetNormalizedPath(icon));
var uri = new Uri(icon);
try
{
@@ -303,7 +298,7 @@ namespace Wox.Infrastructure.Image
BitmapImage image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.UriSource = new Uri(GetNormalizedPath(path));
image.UriSource = new Uri(path);
image.EndInit();
return image;
}

View File

@@ -64,7 +64,7 @@ namespace Wox.Plugin
public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location.NonNull()).ProductVersion;
public static readonly int ThumbnailSize = 64;
public static readonly string ErrorIcon = PathNormalization.NormalizePath(Path.Combine(ProgramDirectory, "Assets", "PowerLauncher", "app_error.dark.png"));
public static readonly string LightThemedErrorIcon = PathNormalization.NormalizePath(Path.Combine(ProgramDirectory, "Assets", "PowerLauncher", "app_error.light.png"));
public static readonly string ErrorIcon = Path.Combine(ProgramDirectory, "Assets", "PowerLauncher", "app_error.dark.png");
public static readonly string LightThemedErrorIcon = Path.Combine(ProgramDirectory, "Assets", "PowerLauncher", "app_error.light.png");
}
}

View File

@@ -1,29 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Wox.Plugin
{
public static class PathNormalization
{
private const string UncPrefix = @"\\?\UNC\";
private const string ExtendedPrefix = @"\\?\";
public static string NormalizePath(string path)
{
if (path.StartsWith(UncPrefix, StringComparison.OrdinalIgnoreCase))
{
return @"\\" + path.Substring(UncPrefix.Length);
}
if (path.StartsWith(ExtendedPrefix, StringComparison.OrdinalIgnoreCase))
{
return path.Substring(ExtendedPrefix.Length);
}
return path;
}
}
}

View File

@@ -1,41 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wox.Plugin;
namespace Wox.Test
{
[TestClass]
public class ImageLoaderTest
{
[DataTestMethod]
// Regular Windows paths should be returned unchanged
[DataRow(@"C:\path\to\file.png", @"C:\path\to\file.png")]
[DataRow(@"C:\Program Files\PowerToys\Assets\PowerLauncher\app_error.dark.png", @"C:\Program Files\PowerToys\Assets\PowerLauncher\app_error.dark.png")]
// UNC paths should be returned unchanged
[DataRow(@"\\server\share\path\file.png", @"\\server\share\path\file.png")]
// Extended-length local paths (\\?\C:\...) should have the \\?\ prefix stripped
[DataRow(@"\\?\C:\path\to\file.png", @"C:\path\to\file.png")]
[DataRow(@"\\?\C:\Program Files\PowerToys\Assets\app_error.dark.png", @"C:\Program Files\PowerToys\Assets\app_error.dark.png")]
// Extended-length UNC paths (\\?\UNC\server\...) should be converted to \\server\...
[DataRow(@"\\?\UNC\server\share\path\file.png", @"\\server\share\path\file.png")]
[DataRow(@"\\?\UNC\TH50\TH50_c\Program Files\PowerToys\Assets\PowerLauncher\app_error.dark.png", @"\\TH50\TH50_c\Program Files\PowerToys\Assets\PowerLauncher\app_error.dark.png")]
// Case-insensitive matching for the prefix
[DataRow(@"\\?\unc\server\share\path\file.png", @"\\server\share\path\file.png")]
public void GetNormalizedPath_ShouldStripExtendedLengthPrefix(string input, string expected)
{
// Act
string result = PathNormalization.NormalizePath(input);
// Assert
Assert.AreEqual(expected, result);
}
}
}