Skip to content

Commit fc9805f

Browse files
committed
add GetAutoCompleteText method
1 parent 5c1cc79 commit fc9805f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Core.Resource;
1+
using Flow.Launcher.Core.Resource;
22
using Flow.Launcher.Infrastructure;
33
using Flow.Launcher.Plugin.SharedCommands;
44
using System;
@@ -38,6 +38,13 @@ private static string GetPathWithActionKeyword(string path, ResultType type)
3838
return $"{keyword}{formatted_path}";
3939
}
4040

41+
private static string GetAutoCompleteText(string title, Query query, string path, ResultType resultType)
42+
{
43+
return !Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled
44+
? $"{query.ActionKeyword} {title}" // Only Quick Access action keyword is used in this scenario
45+
: GetPathWithActionKeyword(path, resultType);
46+
}
47+
4148
public static Result CreateResult(Query query, SearchResult result)
4249
{
4350
return result.Type switch
@@ -57,9 +64,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
5764
Title = title,
5865
IcoPath = path,
5966
SubTitle = Path.GetDirectoryName(path),
60-
AutoCompleteText = !Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled
61-
? $"{query.ActionKeyword} {title}" // Only Quick Access action keyword is used in this scenario
62-
: GetPathWithActionKeyword(path, ResultType.Folder),
67+
AutoCompleteText = GetAutoCompleteText(title, query, path, ResultType.Folder),
6368
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
6469
CopyText = path,
6570
Action = c =>
@@ -219,14 +224,16 @@ internal static Result CreateFileResult(string filePath, Query query, int score
219224
PreviewImagePath = filePath,
220225
} : Result.PreviewInfo.Default;
221226

227+
var title = Path.GetFileName(filePath);
228+
222229
var result = new Result
223230
{
224-
Title = Path.GetFileName(filePath),
231+
Title = title,
225232
SubTitle = Path.GetDirectoryName(filePath),
226233
IcoPath = filePath,
227234
Preview = preview,
228-
AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File),
229-
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData,
235+
AutoCompleteText = GetAutoCompleteText(title, query, filePath, ResultType.File),
236+
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
230237
Score = score,
231238
CopyText = filePath,
232239
Action = c =>

0 commit comments

Comments
 (0)