Remove redundant code

This commit is contained in:
Jiří Polášek
2026-02-12 19:39:00 +01:00
parent 077e260fdb
commit 44ac1c1fb5
4 changed files with 14 additions and 19 deletions

View File

@@ -57,16 +57,13 @@ internal sealed partial class SwitchToWindowCommand : InvokableCommand
else else
{ {
var p = Process.GetProcessById((int)_window.Process.ProcessID); var p = Process.GetProcessById((int)_window.Process.ProcessID);
if (p is not null) try
{
var processFileName = p.MainModule?.FileName;
Icon = new IconInfo(processFileName);
}
catch
{ {
try
{
var processFileName = p.MainModule?.FileName;
Icon = new IconInfo(processFileName);
}
catch
{
}
} }
} }
} }

View File

@@ -25,7 +25,7 @@ internal static class ContextMenuHelper
{ {
new(new CloseWindowCommand(windowData)) new(new CloseWindowCommand(windowData))
{ {
RequestedShortcut = KeyChordHelpers.FromModifiers(true, false, false, false, (int)VirtualKey.F4, 0), RequestedShortcut = KeyChordHelpers.FromModifiers(true, false, false, false, (int)VirtualKey.F4),
}, },
}; };
@@ -36,7 +36,7 @@ internal static class ContextMenuHelper
{ {
contextMenu.Add(new CommandContextItem(new EndTaskCommand(windowData)) contextMenu.Add(new CommandContextItem(new EndTaskCommand(windowData))
{ {
RequestedShortcut = KeyChordHelpers.FromModifiers(true, false, false, false, (int)VirtualKey.Delete, 0), RequestedShortcut = KeyChordHelpers.FromModifiers(true, false, false, false, (int)VirtualKey.Delete),
IsCritical = true, IsCritical = true,
}); });
} }

View File

@@ -12,6 +12,4 @@ namespace Microsoft.CmdPal.Ext.WindowWalker.Helpers;
/// </summary> /// </summary>
[ComImport] [ComImport]
[Guid("aa509086-5ca9-4c25-8f95-589d3c07b48a")] [Guid("aa509086-5ca9-4c25-8f95-589d3c07b48a")]
internal class CVirtualDesktopManager internal class CVirtualDesktopManager;
{
}

View File

@@ -41,8 +41,8 @@ internal sealed partial class WindowWalkerListPage : DynamicListPage, IDisposabl
{ {
ArgumentNullException.ThrowIfNull(query); ArgumentNullException.ThrowIfNull(query);
_cancellationTokenSource?.Cancel(); _cancellationTokenSource.Cancel();
_cancellationTokenSource?.Dispose(); _cancellationTokenSource.Dispose();
_cancellationTokenSource = new System.Threading.CancellationTokenSource(); _cancellationTokenSource = new System.Threading.CancellationTokenSource();
WindowWalkerCommandsProvider.VirtualDesktopHelperInstance.UpdateDesktopList(); WindowWalkerCommandsProvider.VirtualDesktopHelperInstance.UpdateDesktopList();
@@ -54,7 +54,7 @@ internal sealed partial class WindowWalkerListPage : DynamicListPage, IDisposabl
{ {
if (!SettingsManager.Instance.InMruOrder) if (!SettingsManager.Instance.InMruOrder)
{ {
windows.Sort(static (a, b) => string.Compare(a?.Title, b?.Title, StringComparison.OrdinalIgnoreCase)); windows.Sort(static (a, b) => string.Compare(a.Title, b.Title, StringComparison.OrdinalIgnoreCase));
} }
var results = new Scored<Window>[windows.Count]; var results = new Scored<Window>[windows.Count];
@@ -73,7 +73,7 @@ internal sealed partial class WindowWalkerListPage : DynamicListPage, IDisposabl
private static int ScoreFunction(string q, Window window) private static int ScoreFunction(string q, Window window)
{ {
var titleScore = FuzzyStringMatcher.ScoreFuzzy(q, window.Title); var titleScore = FuzzyStringMatcher.ScoreFuzzy(q, window.Title);
var processNameScore = FuzzyStringMatcher.ScoreFuzzy(q, window.Process?.Name ?? string.Empty); var processNameScore = FuzzyStringMatcher.ScoreFuzzy(q, window.Process.Name ?? string.Empty);
return Math.Max(titleScore, processNameScore); return Math.Max(titleScore, processNameScore);
} }
@@ -91,7 +91,7 @@ internal sealed partial class WindowWalkerListPage : DynamicListPage, IDisposabl
{ {
if (disposing) if (disposing)
{ {
_cancellationTokenSource?.Dispose(); _cancellationTokenSource.Dispose();
_disposed = true; _disposed = true;
} }
} }