Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<system:String x:Key="plugin_explorer_deletefilefolderconfirm">Are you sure you want to permanently delete this {0}?</system:String>
<system:String x:Key="plugin_explorer_deletefilefoldersuccess">Deletion successful</system:String>
<system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted the {0}</system:String>
<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>

<!--Controls-->
<system:String x:Key="plugin_explorer_delete">Delete</system:String>
Expand Down
2 changes: 2 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ internal static class Constants

internal const char AllFilesFolderSearchWildcard = '>';

internal const string DefaultContentSearchActionKeyword = "doc:";

internal const char DirectorySeperator = '\\';

internal const string WindowsIndexingOptions = "srchadmin.dll";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks
{
public class QuickFolderAccess
{
internal List<Result> FolderList(Query query, List<FolderLink> folderLinks, PluginInitContext context)
internal List<Result> FolderListMatched(Query query, List<FolderLink> folderLinks, PluginInitContext context)
{
if (string.IsNullOrEmpty(query.Search))
return folderLinks
.Select(item =>
new ResultManager(context)
.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
.ToList();
return new List<Result>();

string search = query.Search.ToLower();

Expand All @@ -24,5 +20,11 @@ internal List<Result> FolderList(Query query, List<FolderLink> folderLinks, Plug
.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
.ToList();
}

internal List<Result> FolderListAll(Query query, List<FolderLink> folderLinks, PluginInitContext context)
=> folderLinks
.Select(item =>
new ResultManager(context).CreateFolderResult(item.Nickname, item.Path, item.Path, query))
.ToList();
}
}
29 changes: 19 additions & 10 deletions Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ internal List<Result> Search(Query query)

var querySearch = query.Search;

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

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

if (string.IsNullOrEmpty(querySearch))
return results;
var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks, context);

if (IsFileContentSearch(query.ActionKeyword))
return WindowsIndexFileContentSearch(query, querySearch);
if (quickFolderLinks.Count > 0)
results.AddRange(quickFolderLinks);

var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);

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

if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariablePath)
return WindowsIndexFilesAndFoldersSearch(query, querySearch);
{
results.AddRange(WindowsIndexFilesAndFoldersSearch(query, querySearch));

return results;
}

var locationPath = querySearch;

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

private bool UseWindowsIndexForDirectorySearch(string locationPath)
{
var pathToDirectory = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath);

if (!settings.UseWindowsIndexForDirectorySearch)
return false;

if (settings.IndexSearchExcludedSubdirectoryPaths
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath)
.Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory)
.StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)))
return false;

return indexSearch.PathIsIndexed(locationPath);
return indexSearch.PathIsIndexed(pathToDirectory);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal class IndexSearch
private readonly ResultManager resultManager;

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

internal IndexSearch(PluginInitContext context)
{
Expand Down
5 changes: 3 additions & 2 deletions Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
using Newtonsoft.Json;
using System.Collections.Generic;

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

[JsonProperty]
public string FileContentSearchActionKeyword { get; set; } = "doc:";
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ internal void UpdateActionKeyword(string newActionKeyword, string oldActionKeywo
}

internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);

internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ private void OnConfirmButtonClick(object sender, RoutedEventArgs e)

return;
}

if (settingsViewModel.IsNewActionKeywordGlobal(newActionKeyword)
&& currentActionKeyword.Description
== settingsViewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch"))
{
MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));

return;
}

if(!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword))
if (!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword))
{
settingsViewModel.UpdateActionKeyword(newActionKeyword, currentActionKeyword.Keyword);

Expand Down