Skip to content

Commit 285b111

Browse files
authored
Fix: Fixed issue where removing an item from the recent list didn't work (#12273)
1 parent e7d3d6d commit 285b111

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Files.App/Shell/ContextMenu.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public async Task<bool> InvokeVerb(string? verb)
4949
if (string.IsNullOrEmpty(verb))
5050
return false;
5151

52+
var item = Items.Where(x => x.CommandString == verb).FirstOrDefault();
53+
if (item is not null && item.ID >= 0)
54+
// Prefer invocation by ID
55+
return await InvokeItem(item.ID);
56+
5257
try
5358
{
5459
var currentWindows = Win32API.GetDesktopWindows();
@@ -73,10 +78,10 @@ public async Task<bool> InvokeVerb(string? verb)
7378
return false;
7479
}
7580

76-
public async Task InvokeItem(int itemID)
81+
public async Task<bool> InvokeItem(int itemID)
7782
{
7883
if (itemID < 0)
79-
return;
84+
return false;
8085

8186
try
8287
{
@@ -90,13 +95,16 @@ public async Task InvokeItem(int itemID)
9095
pici.cbSize = (uint)Marshal.SizeOf(pici);
9196

9297
await owningThread.PostMethod(() => cMenu.InvokeCommand(pici));
93-
9498
Win32API.BringToForeground(currentWindows);
99+
100+
return true;
95101
}
96102
catch (Exception ex) when (ex is COMException or UnauthorizedAccessException)
97103
{
98104
Debug.WriteLine(ex);
99105
}
106+
107+
return false;
100108
}
101109

102110
#region FactoryMethods

0 commit comments

Comments
 (0)