Merge pull request #863 from Garulf/add-auto-complete-to-file-explorer

This commit is contained in:
Garulf 2021-12-07 21:52:21 -05:00 committed by GitHub
commit efd2b78e38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View file

@ -20,6 +20,21 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Settings = settings;
}
private static string GetPathWithActionKeyword(string path, ResultType type)
{
// one of it is enabled
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;
keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";
var formatted_path = path;
if (type == ResultType.Folder)
formatted_path = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
return $"{keyword}{formatted_path}";
}
internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, int score = 0, bool showIndexState = false, bool windowsIndexed = false)
{
return new Result
@ -27,6 +42,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Title = title,
IcoPath = path,
SubTitle = subtitle,
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
Action = c =>
{
@ -43,13 +59,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return false;
}
}
// one of it is enabled
var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword;
keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " ";
string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator;
Context.API.ChangeQuery($"{keyword}{changeTo}");
Context.API.ChangeQuery(GetPathWithActionKeyword(path, ResultType.Folder));
return false;
},
Score = score,
@ -97,6 +109,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Title = title,
SubTitle = $"Use > to search within {subtitleFolderName}, " +
$"* to search for file extensions or >* to combine both searches.",
AutoCompleteText = GetPathWithActionKeyword(retrievedDirectoryPath, ResultType.Folder),
IcoPath = retrievedDirectoryPath,
Score = 500,
Action = c =>
@ -123,6 +136,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Title = Path.GetFileName(filePath),
SubTitle = filePath,
IcoPath = filePath,
AutoCompleteText = GetPathWithActionKeyword(filePath, ResultType.File),
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData,
Score = score,
Action = c =>

View file

@ -10,7 +10,7 @@
"Name": "Explorer",
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
"Author": "Jeremy Wu",
"Version": "1.10.1",
"Version": "1.11.0",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",