@@ -26,6 +26,7 @@ private class PathEqualityComparator : IEqualityComparer<Result>
26
26
{
27
27
private static PathEqualityComparator instance ;
28
28
public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator ( ) ;
29
+
29
30
public bool Equals ( Result x , Result y )
30
31
{
31
32
return x . SubTitle == y . SubTitle ;
@@ -46,25 +47,39 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
46
47
47
48
var result = new HashSet < Result > ( PathEqualityComparator . Instance ) ;
48
49
49
- if ( ActionKeywordMatch ( query , settings . PathSearchActionKeyword ) )
50
+ if ( ActionKeywordMatch ( query , Settings . ActionKeyword . PathSearchActionKeyword ) ||
51
+ ActionKeywordMatch ( query , Settings . ActionKeyword . SearchActionKeyword ) )
50
52
{
51
53
result . UnionWith ( await PathSearchAsync ( query , token ) . ConfigureAwait ( false ) ) ;
52
54
}
53
55
54
- if ( ActionKeywordMatch ( query , settings . SearchActionKeyword ) &&
55
- querySearch . Length > 0 &&
56
- ! querySearch . IsLocationPathString ( ) )
56
+ if ( ( ActionKeywordMatch ( query , Settings . ActionKeyword . IndexOnlySearchActionKeyword ) ||
57
+ ActionKeywordMatch ( query , Settings . ActionKeyword . SearchActionKeyword ) ) &&
58
+ querySearch . Length > 0 &&
59
+ ! querySearch . IsLocationPathString ( ) )
57
60
{
58
- result . UnionWith ( await WindowsIndexFilesAndFoldersSearchAsync ( query , querySearch , token ) . ConfigureAwait ( false ) ) ;
61
+ result . UnionWith ( await WindowsIndexFilesAndFoldersSearchAsync ( query , querySearch , token )
62
+ . ConfigureAwait ( false ) ) ;
59
63
}
60
64
61
65
return result . ToList ( ) ;
62
66
}
63
67
64
- private bool ActionKeywordMatch ( Query query , string actionKeyword )
68
+ private bool ActionKeywordMatch ( Query query , Settings . ActionKeyword allowedActionKeyword )
65
69
{
66
- return query . ActionKeyword == actionKeyword ||
67
- query . ActionKeyword . Length == 0 && actionKeyword == Query . GlobalPluginWildcardSign ;
70
+ var keyword = query . ActionKeyword . Length == 0 ? "*" : query . ActionKeyword ;
71
+
72
+ return allowedActionKeyword switch
73
+ {
74
+ Settings . ActionKeyword . SearchActionKeyword => settings . EnableSearchActionKeyword &&
75
+ keyword == settings . SearchActionKeyword ,
76
+ Settings . ActionKeyword . PathSearchActionKeyword => settings . EnabledPathSearchKeyword &&
77
+ keyword == settings . PathSearchActionKeyword ,
78
+ Settings . ActionKeyword . FileContentSearchActionKeyword => keyword ==
79
+ settings . FileContentSearchActionKeyword ,
80
+ Settings . ActionKeyword . IndexOnlySearchActionKeyword => settings . EnabledIndexOnlySearchKeyword &&
81
+ keyword == settings . IndexOnlySearchActionKeyword
82
+ } ;
68
83
}
69
84
70
85
public async Task < List < Result > > PathSearchAsync ( Query query , CancellationToken token = default )
@@ -118,19 +133,20 @@ public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken t
118
133
return results . ToList ( ) ;
119
134
}
120
135
121
- private async Task < List < Result > > WindowsIndexFileContentSearchAsync ( Query query , string querySearchString , CancellationToken token )
136
+ private async Task < List < Result > > WindowsIndexFileContentSearchAsync ( Query query , string querySearchString ,
137
+ CancellationToken token )
122
138
{
123
139
var queryConstructor = new QueryConstructor ( settings ) ;
124
140
125
141
if ( string . IsNullOrEmpty ( querySearchString ) )
126
142
return new List < Result > ( ) ;
127
143
128
144
return await IndexSearch . WindowsIndexSearchAsync ( querySearchString ,
129
- queryConstructor . CreateQueryHelper ( ) . ConnectionString ,
130
- queryConstructor . QueryForFileContentSearch ,
131
- settings . IndexSearchExcludedSubdirectoryPaths ,
132
- query ,
133
- token ) . ConfigureAwait ( false ) ;
145
+ queryConstructor . CreateQueryHelper ( ) . ConnectionString ,
146
+ queryConstructor . QueryForFileContentSearch ,
147
+ settings . IndexSearchExcludedSubdirectoryPaths ,
148
+ query ,
149
+ token ) . ConfigureAwait ( false ) ;
134
150
}
135
151
136
152
public bool IsFileContentSearch ( string actionKeyword )
@@ -157,28 +173,30 @@ public async Task<List<Result>> TopLevelDirectorySearchBehaviourAsync(
157
173
return await windowsIndexSearch ( query , querySearchString , token ) ;
158
174
}
159
175
160
- private async Task < List < Result > > WindowsIndexFilesAndFoldersSearchAsync ( Query query , string querySearchString , CancellationToken token )
176
+ private async Task < List < Result > > WindowsIndexFilesAndFoldersSearchAsync ( Query query , string querySearchString ,
177
+ CancellationToken token )
161
178
{
162
179
var queryConstructor = new QueryConstructor ( settings ) ;
163
180
164
181
return await IndexSearch . WindowsIndexSearchAsync ( querySearchString ,
165
- queryConstructor . CreateQueryHelper ( ) . ConnectionString ,
166
- queryConstructor . QueryForAllFilesAndFolders ,
167
- settings . IndexSearchExcludedSubdirectoryPaths ,
168
- query ,
169
- token ) . ConfigureAwait ( false ) ;
182
+ queryConstructor . CreateQueryHelper ( ) . ConnectionString ,
183
+ queryConstructor . QueryForAllFilesAndFolders ,
184
+ settings . IndexSearchExcludedSubdirectoryPaths ,
185
+ query ,
186
+ token ) . ConfigureAwait ( false ) ;
170
187
}
171
188
172
- private async Task < List < Result > > WindowsIndexTopLevelFolderSearchAsync ( Query query , string path , CancellationToken token )
189
+ private async Task < List < Result > > WindowsIndexTopLevelFolderSearchAsync ( Query query , string path ,
190
+ CancellationToken token )
173
191
{
174
192
var queryConstructor = new QueryConstructor ( settings ) ;
175
193
176
194
return await IndexSearch . WindowsIndexSearchAsync ( path ,
177
- queryConstructor . CreateQueryHelper ( ) . ConnectionString ,
178
- queryConstructor . QueryForTopLevelDirectorySearch ,
179
- settings . IndexSearchExcludedSubdirectoryPaths ,
180
- query ,
181
- token ) . ConfigureAwait ( false ) ;
195
+ queryConstructor . CreateQueryHelper ( ) . ConnectionString ,
196
+ queryConstructor . QueryForTopLevelDirectorySearch ,
197
+ settings . IndexSearchExcludedSubdirectoryPaths ,
198
+ query ,
199
+ token ) . ConfigureAwait ( false ) ;
182
200
}
183
201
184
202
private bool UseWindowsIndexForDirectorySearch ( string locationPath )
@@ -189,11 +207,11 @@ private bool UseWindowsIndexForDirectorySearch(string locationPath)
189
207
return false ;
190
208
191
209
if ( settings . IndexSearchExcludedSubdirectoryPaths
192
- . Any ( x => FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( pathToDirectory )
193
- . StartsWith ( x . Path , StringComparison . OrdinalIgnoreCase ) ) )
210
+ . Any ( x => FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( pathToDirectory )
211
+ . StartsWith ( x . Path , StringComparison . OrdinalIgnoreCase ) ) )
194
212
return false ;
195
213
196
214
return IndexSearch . PathIsIndexed ( pathToDirectory ) ;
197
215
}
198
216
}
199
- }
217
+ }
0 commit comments