Skip to content

Commit 4bfc733

Browse files
committed
Merge remote-tracking branch 'origin/dev' into fix_plugin_depenedency_loading
2 parents 7fd9c87 + ec5f727 commit 4bfc733

File tree

8 files changed

+46
-20
lines changed

8 files changed

+46
-20
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<system:String x:Key="plugin_explorer_deletefilefolderconfirm">Are you sure you want to permanently delete this {0}?</system:String>
1010
<system:String x:Key="plugin_explorer_deletefilefoldersuccess">Deletion successful</system:String>
1111
<system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted the {0}</system:String>
12+
<system:String x:Key="plugin_explorer_globalActionKeywordInvalid">Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword</system:String>
1213

1314
<!--Controls-->
1415
<system:String x:Key="plugin_explorer_delete">Delete</system:String>

Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ internal static class Constants
2222

2323
internal const char AllFilesFolderSearchWildcard = '>';
2424

25+
internal const string DefaultContentSearchActionKeyword = "doc:";
26+
2527
internal const char DirectorySeperator = '\\';
2628

2729
internal const string WindowsIndexingOptions = "srchadmin.dll";

Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks
66
{
77
public class QuickFolderAccess
88
{
9-
internal List<Result> FolderList(Query query, List<FolderLink> folderLinks, PluginInitContext context)
9+
internal List<Result> FolderListMatched(Query query, List<FolderLink> folderLinks, PluginInitContext context)
1010
{
1111
if (string.IsNullOrEmpty(query.Search))
12-
return folderLinks
13-
.Select(item =>
14-
new ResultManager(context)
15-
.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
16-
.ToList();
12+
return new List<Result>();
1713

1814
string search = query.Search.ToLower();
1915

@@ -24,5 +20,11 @@ internal List<Result> FolderList(Query query, List<FolderLink> folderLinks, Plug
2420
.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
2521
.ToList();
2622
}
23+
24+
internal List<Result> FolderListAll(Query query, List<FolderLink> folderLinks, PluginInitContext context)
25+
=> folderLinks
26+
.Select(item =>
27+
new ResultManager(context).CreateFolderResult(item.Nickname, item.Path, item.Path, query))
28+
.ToList();
2729
}
2830
}

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ internal List<Result> Search(Query query)
3434

3535
var querySearch = query.Search;
3636

37-
var quickFolderLinks = quickFolderAccess.FolderList(query, settings.QuickFolderAccessLinks, context);
37+
if (IsFileContentSearch(query.ActionKeyword))
38+
return WindowsIndexFileContentSearch(query, querySearch);
3839

39-
if (quickFolderLinks.Count > 0 && query.ActionKeyword == settings.SearchActionKeyword)
40-
return quickFolderLinks;
40+
// This allows the user to type the assigned action keyword and only see the list of quick folder links
41+
if (settings.QuickFolderAccessLinks.Count > 0
42+
&& query.ActionKeyword == settings.SearchActionKeyword
43+
&& string.IsNullOrEmpty(query.Search))
44+
return quickFolderAccess.FolderListAll(query, settings.QuickFolderAccessLinks, context);
4145

42-
if (string.IsNullOrEmpty(querySearch))
43-
return results;
46+
var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks, context);
4447

45-
if (IsFileContentSearch(query.ActionKeyword))
46-
return WindowsIndexFileContentSearch(query, querySearch);
48+
if (quickFolderLinks.Count > 0)
49+
results.AddRange(quickFolderLinks);
4750

4851
var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);
4952

@@ -54,7 +57,11 @@ internal List<Result> Search(Query query)
5457
var isEnvironmentVariablePath = querySearch.Substring(1).Contains("%\\");
5558

5659
if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariablePath)
57-
return WindowsIndexFilesAndFoldersSearch(query, querySearch);
60+
{
61+
results.AddRange(WindowsIndexFilesAndFoldersSearch(query, querySearch));
62+
63+
return results;
64+
}
5865

5966
var locationPath = querySearch;
6067

@@ -137,15 +144,17 @@ private List<Result> WindowsIndexTopLevelFolderSearch(Query query, string path)
137144

138145
private bool UseWindowsIndexForDirectorySearch(string locationPath)
139146
{
147+
var pathToDirectory = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath);
148+
140149
if (!settings.UseWindowsIndexForDirectorySearch)
141150
return false;
142151

143152
if (settings.IndexSearchExcludedSubdirectoryPaths
144-
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath)
153+
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory)
145154
.StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)))
146155
return false;
147156

148-
return indexSearch.PathIsIndexed(locationPath);
157+
return indexSearch.PathIsIndexed(pathToDirectory);
149158
}
150159
}
151160
}

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal class IndexSearch
2121
private readonly ResultManager resultManager;
2222

2323
// Reserved keywords in oleDB
24-
private readonly string reservedStringPattern = @"^[\/\\\$\%]+$";
24+
private readonly string reservedStringPattern = @"^[\/\\\$\%_]+$";
2525

2626
internal IndexSearch(PluginInitContext context)
2727
{

Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
1+
using Flow.Launcher.Plugin.Explorer.Search;
2+
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
23
using Newtonsoft.Json;
34
using System.Collections.Generic;
45

@@ -22,6 +23,6 @@ public class Settings
2223
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
2324

2425
[JsonProperty]
25-
public string FileContentSearchActionKeyword { get; set; } = "doc:";
26+
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
2627
}
2728
}

Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,7 @@ internal void UpdateActionKeyword(string newActionKeyword, string oldActionKeywo
5454
}
5555

5656
internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);
57+
58+
internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign;
5759
}
5860
}

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,17 @@ private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
5151

5252
return;
5353
}
54+
55+
if (settingsViewModel.IsNewActionKeywordGlobal(newActionKeyword)
56+
&& currentActionKeyword.Description
57+
== settingsViewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"))
58+
{
59+
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
60+
61+
return;
62+
}
5463

55-
if(!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword))
64+
if (!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword))
5665
{
5766
settingsViewModel.UpdateActionKeyword(newActionKeyword, currentActionKeyword.Keyword);
5867

0 commit comments

Comments
 (0)