@@ -72,6 +72,8 @@ public class Main : ISettingProvider, IAsyncPlugin, IPluginI18n, IContextMenu, I
72
72
private const string ExeUninstallerSuffix = ".exe" ;
73
73
private const string InkUninstallerSuffix = ".lnk" ;
74
74
75
+ private const string WindowsAppPath = "c:\\ program files\\ windowsapps" ;
76
+
75
77
static Main ( )
76
78
{
77
79
}
@@ -90,11 +92,20 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
90
92
{
91
93
try
92
94
{
95
+ // Collect all UWP Windows app directories
96
+ var uwpsDirectories = _settings . HideDulplicatedWindowsApp ? _uwps
97
+ . Where ( uwp => ! string . IsNullOrEmpty ( uwp . Location ) ) // Exclude invalid paths
98
+ . Where ( uwp => uwp . Location . StartsWith ( WindowsAppPath , StringComparison . OrdinalIgnoreCase ) ) // Keep system apps
99
+ . Select ( uwp => uwp . Location . TrimEnd ( '\\ ' ) ) // Remove trailing slash
100
+ . Distinct ( StringComparer . OrdinalIgnoreCase )
101
+ . ToArray ( ) : null ;
102
+
93
103
return _win32s . Cast < IProgram > ( )
94
104
. Concat ( _uwps )
95
105
. AsParallel ( )
96
106
. WithCancellation ( token )
97
107
. Where ( HideUninstallersFilter )
108
+ . Where ( p => HideDulplicatedWindowsAppFilter ( p , uwpsDirectories ) )
98
109
. Where ( p => p . Enabled )
99
110
. Select ( p => p . Result ( query . Search , Context . API ) )
100
111
. Where ( r => r ? . Score > 0 )
@@ -152,6 +163,23 @@ private bool HideUninstallersFilter(IProgram program)
152
163
return true ;
153
164
}
154
165
166
+ private static bool HideDulplicatedWindowsAppFilter ( IProgram program , string [ ] uwpsDirectories )
167
+ {
168
+ if ( uwpsDirectories == null || uwpsDirectories . Length == 0 ) return true ;
169
+ if ( program is UWPApp ) return true ;
170
+
171
+ var location = program . Location . TrimEnd ( '\\ ' ) ; // Ensure trailing slash
172
+ if ( string . IsNullOrEmpty ( location ) )
173
+ return true ; // Keep if location is invalid
174
+
175
+ if ( ! location . StartsWith ( WindowsAppPath , StringComparison . OrdinalIgnoreCase ) )
176
+ return true ; // Keep if not a Windows app
177
+
178
+ // Check if the any Win32 executable directory contains UWP Windows app location matches
179
+ return ! uwpsDirectories . Any ( uwpDirectory =>
180
+ location . StartsWith ( uwpDirectory , StringComparison . OrdinalIgnoreCase ) ) ;
181
+ }
182
+
155
183
public async Task InitAsync ( PluginInitContext context )
156
184
{
157
185
Context = context ;
0 commit comments