Skip to content

Commit efd2b78

Browse files
authored
Merge pull request #863 from Garulf/add-auto-complete-to-file-explorer
2 parents b11f728 + f741420 commit efd2b78

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,29 @@ public static void Init(PluginInitContext context, Settings settings)
2020
Settings = settings;
2121
}
2222

23+
private static string GetPathWithActionKeyword(string path, ResultType type)
24+
{
25+
// one of it is enabled
26+
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;
27+
28+
keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";
29+
30+
var formatted_path = path;
31+
32+
if (type == ResultType.Folder)
33+
formatted_path = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
34+
35+
return $"{keyword}{formatted_path}";
36+
}
37+
2338
internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, int score = 0, bool showIndexState = false, bool windowsIndexed = false)
2439
{
2540
return new Result
2641
{
2742
Title = title,
2843
IcoPath = path,
2944
SubTitle = subtitle,
45+
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
3046
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
3147
Action = c =>
3248
{
@@ -43,13 +59,9 @@ internal static Result CreateFolderResult(string title, string subtitle, string
4359
return false;
4460
}
4561
}
46-
// one of it is enabled
47-
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;
48-
49-
keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";
5062

51-
string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
52-
Context.API.ChangeQuery($"{keyword}{changeTo}");
63+
Context.API.ChangeQuery(GetPathWithActionKeyword(path, ResultType.Folder));
64+
5365
return false;
5466
},
5567
Score = score,
@@ -97,6 +109,7 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
97109
Title = title,
98110
SubTitle = $"Use > to search within {subtitleFolderName}, " +
99111
$"* to search for file extensions or >* to combine both searches.",
112+
AutoCompleteText = GetPathWithActionKeyword(retrievedDirectoryPath, ResultType.Folder),
100113
IcoPath = retrievedDirectoryPath,
101114
Score = 500,
102115
Action = c =>
@@ -123,6 +136,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
123136
Title = Path.GetFileName(filePath),
124137
SubTitle = filePath,
125138
IcoPath = filePath,
139+
AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File),
126140
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData,
127141
Score = score,
128142
Action = c =>

Plugins/Flow.Launcher.Plugin.Explorer/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"Name": "Explorer",
1111
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
1212
"Author": "Jeremy Wu",
13-
"Version": "1.10.1",
13+
"Version": "1.11.0",
1414
"Language": "csharp",
1515
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1616
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",

0 commit comments

Comments
 (0)