Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c979609
new keywords in settings
01Dri Oct 29, 2025
531e8c7
settings keywords
01Dri Oct 29, 2025
dbe7d52
ActionKeywordConfiguration
01Dri Oct 30, 2025
e0a99c5
adjust
01Dri Nov 1, 2025
9209b93
up
01Dri Nov 2, 2025
d2dd16b
up
01Dri Nov 2, 2025
fbb26e9
switch case adjust
01Dri Nov 2, 2025
c90de6f
code quality
01Dri Nov 2, 2025
20959dc
code quality
01Dri Nov 2, 2025
4107b87
code quality
01Dri Nov 3, 2025
a4d3c80
Merge branch 'dev' into feature/new_action_keywords
01Dri Nov 3, 2025
30dbdb8
Option to exclude quick access from results
01Dri Nov 5, 2025
0a0cd3e
code quality
01Dri Nov 5, 2025
4e5378b
code quality
01Dri Nov 5, 2025
dbf4491
Apply suggestion from @Copilot
Jack251970 Nov 9, 2025
945a3d6
Apply suggestion from @Copilot
Jack251970 Nov 9, 2025
b67a608
Apply suggestion from @Copilot
Jack251970 Nov 9, 2025
dcf4b46
Simplify logic
Jack251970 Nov 9, 2025
1d60cb7
Apply suggestion from @Copilot
Jack251970 Nov 9, 2025
558967d
Code cleanup
Jack251970 Nov 9, 2025
24d212f
Code cleanup
Jack251970 Nov 9, 2025
592f60a
Code cleanup
Jack251970 Nov 9, 2025
ed5debf
fix: path search trigger in general search
01Dri Nov 22, 2025
fc573bd
Merge branch 'dev' into feature/new_action_keywords
01Dri Nov 22, 2025
1cdbdd0
refactor: option to exclude quick access result from action keywords …
01Dri Nov 29, 2025
69e2031
Merge branch 'feature/new_action_keywords' of https://github.com/01Dr…
01Dri Nov 29, 2025
8b7cbf7
up
01Dri Nov 29, 2025
438e709
refactor: GetActiveActionKeywords method doc
01Dri Nov 29, 2025
bd8179d
Merge branch 'dev' into feature/new_action_keywords
01Dri Nov 29, 2025
13dad55
refactor: fix search file and folder
01Dri Nov 29, 2025
6da9b80
Merge branch 'feature/new_action_keywords' of https://github.com/01Dr…
01Dri Nov 29, 2025
1150f19
up
01Dri Nov 29, 2025
8e34897
fix PR comments
01Dri Dec 5, 2025
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
2 changes: 2 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">File Content Search:</system:String>
<system:String x:Key="plugin_explorer_actionkeywordview_indexsearch">Index Search:</system:String>
<system:String x:Key="plugin_explorer_actionkeywordview_quickaccess">Quick Access:</system:String>
<system:String x:Key="plugin_explorer_actionkeywordview_foldersearch">Folder Search:</system:String>
<system:String x:Key="plugin_explorer_actionkeywordview_filesearch">File Search:</system:String>
<system:String x:Key="plugin_explorer_actionkeyword_current">Current Action Keyword</system:String>
<system:String x:Key="plugin_explorer_actionkeyword_done">Done</system:String>
<system:String x:Key="plugin_explorer_actionkeyword_enabled">Enabled</system:String>
Expand All @@ -74,7 +76,7 @@
<system:String x:Key="plugin_explorer_Directory_Recursive_Search_Engine">Directory Recursive Search Engine</system:String>
<system:String x:Key="plugin_explorer_Index_Search_Engine">Index Search Engine</system:String>
<system:String x:Key="plugin_explorer_Open_Window_Index_Option">Open Windows Index Option</system:String>
<system:String x:Key="plugin_explorer_Excluded_File_Types">Excluded File Types (comma seperated)</system:String>

Check warning on line 79 in Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`seperated` is not a recognized word. (unrecognized-spelling)
<system:String x:Key="plugin_explorer_Excluded_File_Types_Tooltip">For example: exe,jpg,png</system:String>
<system:String x:Key="plugin_explorer_Maximum_Results">Maximum results</system:String>
<system:String x:Key="plugin_explorer_Maximum_Results_Tooltip">The maximum number of results requested from active search engine</system:String>
Expand Down
203 changes: 129 additions & 74 deletions Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
using Flow.Launcher.Plugin.Explorer.Search.Everything;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.SharedCommands;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Documents;
using Flow.Launcher.Plugin.Explorer.Exceptions;
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
using Flow.Launcher.Plugin.Explorer.Search.Everything;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.SharedCommands;
using static Flow.Launcher.Plugin.Explorer.Settings;
using Path = System.IO.Path;

namespace Flow.Launcher.Plugin.Explorer.Search
Expand All @@ -18,6 +20,13 @@

internal Settings Settings;

private readonly Dictionary<ActionKeyword, List<ResultType>> _typesToFilterByActionKeyword = new()
{
{ ActionKeyword.FileSearchActionKeyword, [ResultType.Folder, ResultType.Volume] },
{ ActionKeyword.FolderSearchActionKeyword, [ResultType.File] },
};


public SearchManager(Settings settings, PluginInitContext context)
{
Context = context;
Expand All @@ -31,7 +40,7 @@
{
private static PathEqualityComparator instance;
public static PathEqualityComparator Instance => instance ??= new PathEqualityComparator();

public bool Equals(Result x, Result y)
{
return x.Title.Equals(y.Title, StringComparison.OrdinalIgnoreCase)
Expand All @@ -47,83 +56,92 @@
internal async Task<List<Result>> SearchAsync(Query query, CancellationToken token)
{
var results = new HashSet<Result>(PathEqualityComparator.Instance);
var keyword = query.ActionKeyword.Length == 0 ? Query.GlobalPluginWildcardSign : query.ActionKeyword;
// No action keyword matched - plugin should not handle this query, return empty results.
var activeActionKeywords = Settings.GetActiveActionKeywords(keyword);
if (activeActionKeywords.Count == 0)
{
return [];
}
var isPathSearch = query.Search.IsLocationPathString()
|| EnvironmentVariables.IsEnvironmentVariableSearch(query.Search)
|| EnvironmentVariables.HasEnvironmentVar(query.Search);

// This allows the user to type the below action keywords and see/search the list of quick folder links
if (ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)
|| ActionKeywordMatch(query, Settings.ActionKeyword.QuickAccessActionKeyword)
|| ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword)
|| ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword)
|| ActionKeywordMatch(query, Settings.ActionKeyword.FileContentSearchActionKeyword))
var queryIsEmpty = string.IsNullOrEmpty(query.Search);

if (queryIsEmpty && activeActionKeywords.ContainsKey(ActionKeyword.QuickAccessActionKeyword))
{
if (string.IsNullOrEmpty(query.Search) && ActionKeywordMatch(query, Settings.ActionKeyword.QuickAccessActionKeyword))
return QuickAccess.AccessLinkListAll(query, Settings.QuickAccessLinks);
return QuickAccess.AccessLinkListAll(query, Settings.QuickAccessLinks);
}
else

// If query is empty and active keyword is folder or search, return empty results.
if (queryIsEmpty && (activeActionKeywords.ContainsKey(ActionKeyword.FolderSearchActionKeyword)
|| activeActionKeywords.ContainsKey(ActionKeyword.FileSearchActionKeyword)))
{
// No action keyword matched- plugin should not handle this query, return empty results.
return new List<Result>();
return [];
}

IAsyncEnumerable<SearchResult> searchResults;
// When file search is active, do not include path search in the active keywords.
// This prevents unwanted PathSearch results (e.g., drives or raw volume paths).
if (isPathSearch && !activeActionKeywords.ContainsKey(ActionKeyword.PathSearchActionKeyword)
&& !activeActionKeywords.ContainsKey(ActionKeyword.FileSearchActionKeyword))
{
activeActionKeywords.Add(ActionKeyword.PathSearchActionKeyword, keyword);
}

bool isPathSearch = query.Search.IsLocationPathString()
|| EnvironmentVariables.IsEnvironmentVariableSearch(query.Search)
|| EnvironmentVariables.HasEnvironmentVar(query.Search);
IAsyncEnumerable<SearchResult> searchResults;

string engineName;

switch (isPathSearch)
{
case true
when ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword)
|| ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword):

when activeActionKeywords.ContainsKey(ActionKeyword.PathSearchActionKeyword)
|| activeActionKeywords.ContainsKey(ActionKeyword.SearchActionKeyword):
results.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false));

return results.ToList();
return [.. results];

case false
when ActionKeywordMatch(query, Settings.ActionKeyword.FileContentSearchActionKeyword):

// Intentionally require enabling of Everything's content search due to its slowness
when activeActionKeywords.ContainsKey(ActionKeyword.FileContentSearchActionKeyword):
if (Settings.ContentIndexProvider is EverythingSearchManager && !Settings.EnableEverythingContentSearch)
return EverythingContentSearchResult(query);

searchResults = Settings.ContentIndexProvider.ContentSearchAsync("", query.Search, token);
engineName = Enum.GetName(Settings.ContentSearchEngine);
break;

case false
when ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword)
|| ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword):
case true or false
when activeActionKeywords.ContainsKey(ActionKeyword.QuickAccessActionKeyword):
return QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks);


case false
when CanUseIndexSearchByActionKeywords(activeActionKeywords):
searchResults = Settings.IndexProvider.SearchAsync(query.Search, token);
engineName = Enum.GetName(Settings.IndexSearchEngine);
break;

case true or false
when ActionKeywordMatch(query, Settings.ActionKeyword.QuickAccessActionKeyword):
return QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks);

default:
return results.ToList();
}
return [..results];

// Merge Quick Access Link results for non-path searches.
results.UnionWith(QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks));
}

//Merge Quick Access Link results for non-path searches.
results.UnionWith(GetQuickAccessResultsFilteredByActionKeyword(query, activeActionKeywords));
try
{
await foreach (var search in searchResults.WithCancellation(token).ConfigureAwait(false))
if (search.Type == ResultType.File && IsExcludedFile(search)) {
{
if (ShouldSkipResultByTypeAndActionKeyword(activeActionKeywords, search))
{
continue;
} else {
results.Add(ResultManager.CreateResult(query, search));
}
results.Add(ResultManager.CreateResult(query, search));
}
}
catch (OperationCanceledException)
{
return new List<Result>();
return [.. results];
}
catch (EngineNotAvailableException)
{
Expand All @@ -137,33 +155,13 @@
results.RemoveWhere(r => Settings.IndexSearchExcludedSubdirectoryPaths.Any(
excludedPath => FilesFolders.PathContains(excludedPath.Path, r.SubTitle, allowEqual: true)));

return results.ToList();
}

private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActionKeyword)
{
var keyword = query.ActionKeyword.Length == 0 ? Query.GlobalPluginWildcardSign : query.ActionKeyword;

return allowedActionKeyword switch
{
Settings.ActionKeyword.SearchActionKeyword => Settings.SearchActionKeywordEnabled &&
keyword == Settings.SearchActionKeyword,
Settings.ActionKeyword.PathSearchActionKeyword => Settings.PathSearchKeywordEnabled &&
keyword == Settings.PathSearchActionKeyword,
Settings.ActionKeyword.FileContentSearchActionKeyword => Settings.FileContentSearchKeywordEnabled &&
keyword == Settings.FileContentSearchActionKeyword,
Settings.ActionKeyword.IndexSearchActionKeyword => Settings.IndexSearchKeywordEnabled &&
keyword == Settings.IndexSearchActionKeyword,
Settings.ActionKeyword.QuickAccessActionKeyword => Settings.QuickAccessKeywordEnabled &&
keyword == Settings.QuickAccessActionKeyword,
_ => throw new ArgumentOutOfRangeException(nameof(allowedActionKeyword), allowedActionKeyword, "actionKeyword out of range")
};
return [.. results];
}

private List<Result> EverythingContentSearchResult(Query query)
{
return new List<Result>()
{
return
[
new()
{
Title = Localize.flowlauncher_plugin_everything_enable_content_search(),
Expand All @@ -176,7 +174,7 @@
return false;
}
}
};
];
}

private async Task<List<Result>> PathSearchAsync(Query query, CancellationToken token = default)
Expand All @@ -188,7 +186,7 @@
if (EnvironmentVariables.IsEnvironmentVariableSearch(querySearch))
return EnvironmentVariables.GetEnvironmentStringPathSuggestions(querySearch, query, Context);

// Query is a location path with a full environment variable, eg. %appdata%\somefolder\, c:\users\%USERNAME%\downloads

Check warning on line 189 in Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`somefolder` is not a recognized word. (unrecognized-spelling)
var needToExpand = EnvironmentVariables.HasEnvironmentVar(querySearch);
var path = needToExpand ? Environment.ExpandEnvironmentVariables(querySearch) : querySearch;

Expand All @@ -197,7 +195,7 @@

// Check that actual location exists, otherwise directory search will throw directory not found exception
if (!FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path).LocationExists())
return results.ToList();
return [.. results];

var useIndexSearch = Settings.IndexSearchEngine is Settings.IndexSearchEngineOption.WindowsIndex
&& UseWindowsIndexForDirectorySearch(path);
Expand All @@ -209,7 +207,7 @@
: ResultManager.CreateOpenCurrentFolderResult(retrievedDirectoryPath, query.ActionKeyword, useIndexSearch));

if (token.IsCancellationRequested)
return new List<Result>();
return [.. results];

IAsyncEnumerable<SearchResult> directoryResult;

Expand All @@ -231,7 +229,7 @@
}

if (token.IsCancellationRequested)
return new List<Result>();
return [.. results];

try
{
Expand All @@ -246,14 +244,14 @@
}


return results.ToList();
return [.. results];
}

public bool IsFileContentSearch(string actionKeyword) => actionKeyword == Settings.FileContentSearchActionKeyword;

public static bool UseIndexSearch(string path)
{
if (Main.Settings.IndexSearchEngine is not Settings.IndexSearchEngineOption.WindowsIndex)
if (Main.Settings.IndexSearchEngine is not IndexSearchEngineOption.WindowsIndex)
return false;

// Check if the path is using windows index search
Expand All @@ -275,10 +273,67 @@

private bool IsExcludedFile(SearchResult result)
{
string[] excludedFileTypes = Settings.ExcludedFileTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
string[] excludedFileTypes = Settings.ExcludedFileTypes.Split([','], StringSplitOptions.RemoveEmptyEntries);
string fileExtension = Path.GetExtension(result.FullPath).TrimStart('.');

return excludedFileTypes.Contains(fileExtension, StringComparer.OrdinalIgnoreCase);
}

private bool ShouldSkipResultByTypeAndActionKeyword(Dictionary<ActionKeyword, string> actions, SearchResult search)
{
// Is excluded file type
if (search.Type == ResultType.File && IsExcludedFile(search))
{
return true;
}
return IsResultTypeFilteredByActionKeyword(search.Type, actions);

}

private List<Result> GetQuickAccessResultsFilteredByActionKeyword(Query query, Dictionary<ActionKeyword, string> actions)
{
var results = QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks) ?? [];
if (results.Count == 0)
{
return results;
}

return results
.Where(r => r.ContextData is SearchResult result
&& !IsResultTypeFilteredByActionKeyword(result.Type, actions))
.ToList();
}
private bool IsResultTypeFilteredByActionKeyword(ResultType type, Dictionary<ActionKeyword, string> actions)
{
foreach (var action in actions.Keys)
{
if (_typesToFilterByActionKeyword.TryGetValue(action, out var typesToFilter))
{
return typesToFilter.Contains(type);
}
}

return false;
}

private bool CanUseIndexSearchByActionKeywords(Dictionary<ActionKeyword, string> actions)
{
List<ActionKeyword> keysToUseSearch =
[
ActionKeyword.FileSearchActionKeyword,
ActionKeyword.FolderSearchActionKeyword,
ActionKeyword.IndexSearchActionKeyword,
ActionKeyword.SearchActionKeyword
];
foreach (var key in keysToUseSearch)
{
var contains = actions.ContainsKey(key);
if (!contains) continue;
return contains;
}

return false;
}

}
}
Loading
Loading