@@ -12,14 +12,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search
12
12
{
13
13
public class SearchManager
14
14
{
15
- private readonly PluginInitContext context ;
15
+ internal static PluginInitContext Context ;
16
16
17
- private readonly Settings settings ;
17
+ internal static Settings Settings ;
18
18
19
19
public SearchManager ( Settings settings , PluginInitContext context )
20
20
{
21
- this . context = context ;
22
- this . settings = settings ;
21
+ Context = context ;
22
+ Settings = settings ;
23
23
}
24
24
25
25
private class PathEqualityComparator : IEqualityComparer < Result >
@@ -71,14 +71,14 @@ private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActio
71
71
72
72
return allowedActionKeyword switch
73
73
{
74
- Settings . ActionKeyword . SearchActionKeyword => settings . SearchActionKeywordEnabled &&
75
- keyword == settings . SearchActionKeyword ,
76
- Settings . ActionKeyword . PathSearchActionKeyword => settings . PathSearchKeywordEnabled &&
77
- keyword == settings . PathSearchActionKeyword ,
74
+ Settings . ActionKeyword . SearchActionKeyword => Settings . SearchActionKeywordEnabled &&
75
+ keyword == Settings . SearchActionKeyword ,
76
+ Settings . ActionKeyword . PathSearchActionKeyword => Settings . PathSearchKeywordEnabled &&
77
+ keyword == Settings . PathSearchActionKeyword ,
78
78
Settings . ActionKeyword . FileContentSearchActionKeyword => keyword ==
79
- settings . FileContentSearchActionKeyword ,
80
- Settings . ActionKeyword . IndexSearchActionKeyword => settings . IndexOnlySearchKeywordEnabled &&
81
- keyword == settings . IndexSearchActionKeyword
79
+ Settings . FileContentSearchActionKeyword ,
80
+ Settings . ActionKeyword . IndexSearchActionKeyword => Settings . IndexOnlySearchKeywordEnabled &&
81
+ keyword == Settings . IndexSearchActionKeyword
82
82
} ;
83
83
}
84
84
@@ -88,18 +88,18 @@ public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken t
88
88
89
89
// This allows the user to type the assigned action keyword and only see the list of quick folder links
90
90
if ( string . IsNullOrEmpty ( query . Search ) )
91
- return QuickAccess . AccessLinkListAll ( query , settings . QuickAccessLinks ) ;
91
+ return QuickAccess . AccessLinkListAll ( query , Settings . QuickAccessLinks ) ;
92
92
93
93
var results = new HashSet < Result > ( PathEqualityComparator . Instance ) ;
94
94
95
- var quickaccessLinks = QuickAccess . AccessLinkListMatched ( query , settings . QuickAccessLinks ) ;
95
+ var quickaccessLinks = QuickAccess . AccessLinkListMatched ( query , Settings . QuickAccessLinks ) ;
96
96
97
97
results . UnionWith ( quickaccessLinks ) ;
98
98
99
99
var isEnvironmentVariable = EnvironmentVariables . IsEnvironmentVariableSearch ( querySearch ) ;
100
100
101
101
if ( isEnvironmentVariable )
102
- return EnvironmentVariables . GetEnvironmentStringPathSuggestions ( querySearch , query , context ) ;
102
+ return EnvironmentVariables . GetEnvironmentStringPathSuggestions ( querySearch , query , Context ) ;
103
103
104
104
// Query is a location path with a full environment variable, eg. %appdata%\somefolder\
105
105
var isEnvironmentVariablePath = querySearch [ 1 ..] . Contains ( "%\\ " ) ;
@@ -136,22 +136,23 @@ public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken t
136
136
private async Task < List < Result > > WindowsIndexFileContentSearchAsync ( Query query , string querySearchString ,
137
137
CancellationToken token )
138
138
{
139
- var queryConstructor = new QueryConstructor ( settings ) ;
139
+ var queryConstructor = new QueryConstructor ( Settings ) ;
140
140
141
141
if ( string . IsNullOrEmpty ( querySearchString ) )
142
142
return new List < Result > ( ) ;
143
143
144
- return await IndexSearch . WindowsIndexSearchAsync ( querySearchString ,
145
- queryConstructor . CreateQueryHelper ( ) . ConnectionString ,
144
+ return await IndexSearch . WindowsIndexSearchAsync (
145
+ querySearchString ,
146
+ queryConstructor . CreateQueryHelper ( ) ,
146
147
queryConstructor . QueryForFileContentSearch ,
147
- settings . IndexSearchExcludedSubdirectoryPaths ,
148
+ Settings . IndexSearchExcludedSubdirectoryPaths ,
148
149
query ,
149
150
token ) . ConfigureAwait ( false ) ;
150
151
}
151
152
152
153
public bool IsFileContentSearch ( string actionKeyword )
153
154
{
154
- return actionKeyword == settings . FileContentSearchActionKeyword ;
155
+ return actionKeyword == Settings . FileContentSearchActionKeyword ;
155
156
}
156
157
157
158
private List < Result > DirectoryInfoClassSearch ( Query query , string querySearch , CancellationToken token )
@@ -176,25 +177,27 @@ public async Task<List<Result>> TopLevelDirectorySearchBehaviourAsync(
176
177
private async Task < List < Result > > WindowsIndexFilesAndFoldersSearchAsync ( Query query , string querySearchString ,
177
178
CancellationToken token )
178
179
{
179
- var queryConstructor = new QueryConstructor ( settings ) ;
180
+ var queryConstructor = new QueryConstructor ( Settings ) ;
180
181
181
- return await IndexSearch . WindowsIndexSearchAsync ( querySearchString ,
182
- queryConstructor . CreateQueryHelper ( ) . ConnectionString ,
182
+ return await IndexSearch . WindowsIndexSearchAsync (
183
+ querySearchString ,
184
+ queryConstructor . CreateQueryHelper ( ) ,
183
185
queryConstructor . QueryForAllFilesAndFolders ,
184
- settings . IndexSearchExcludedSubdirectoryPaths ,
186
+ Settings . IndexSearchExcludedSubdirectoryPaths ,
185
187
query ,
186
188
token ) . ConfigureAwait ( false ) ;
187
189
}
188
190
189
191
private async Task < List < Result > > WindowsIndexTopLevelFolderSearchAsync ( Query query , string path ,
190
192
CancellationToken token )
191
193
{
192
- var queryConstructor = new QueryConstructor ( settings ) ;
194
+ var queryConstructor = new QueryConstructor ( Settings ) ;
193
195
194
- return await IndexSearch . WindowsIndexSearchAsync ( path ,
195
- queryConstructor . CreateQueryHelper ( ) . ConnectionString ,
196
+ return await IndexSearch . WindowsIndexSearchAsync (
197
+ path ,
198
+ queryConstructor . CreateQueryHelper ( ) ,
196
199
queryConstructor . QueryForTopLevelDirectorySearch ,
197
- settings . IndexSearchExcludedSubdirectoryPaths ,
200
+ Settings . IndexSearchExcludedSubdirectoryPaths ,
198
201
query ,
199
202
token ) . ConfigureAwait ( false ) ;
200
203
}
@@ -203,10 +206,10 @@ private bool UseWindowsIndexForDirectorySearch(string locationPath)
203
206
{
204
207
var pathToDirectory = FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( locationPath ) ;
205
208
206
- if ( ! settings . UseWindowsIndexForDirectorySearch )
209
+ if ( ! Settings . UseWindowsIndexForDirectorySearch )
207
210
return false ;
208
211
209
- if ( settings . IndexSearchExcludedSubdirectoryPaths
212
+ if ( Settings . IndexSearchExcludedSubdirectoryPaths
210
213
. Any ( x => FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( pathToDirectory )
211
214
. StartsWith ( x . Path , StringComparison . OrdinalIgnoreCase ) ) )
212
215
return false ;
0 commit comments