mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add first result as opening current directory
This commit is contained in:
parent
b03ee66646
commit
74b25c0bf1
2 changed files with 56 additions and 11 deletions
|
|
@ -45,24 +45,41 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
};
|
||||
}
|
||||
|
||||
internal static Result CreateOpenCurrentFolderResult(string incompleteName, string search)
|
||||
internal static Result CreateOpenCurrentFolderResult(string path, bool isPreviousDirectoryLevel)
|
||||
{
|
||||
var firstResult = "Open current directory";
|
||||
if (incompleteName.Length > 0)
|
||||
firstResult = "Open " + search;
|
||||
var folderName = path;
|
||||
|
||||
var folderName = search.TrimEnd('\\').Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last();
|
||||
if (folderName.EndsWith(":\\"))
|
||||
{
|
||||
var driveLetter = folderName.Substring(0, 1).ToUpper();
|
||||
folderName = driveLetter + " drive";
|
||||
}
|
||||
else
|
||||
{
|
||||
folderName = folderName.TrimEnd('\\').Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last();
|
||||
}
|
||||
|
||||
var firstResult = "";
|
||||
|
||||
if (isPreviousDirectoryLevel)
|
||||
{
|
||||
firstResult = "Open " + folderName;
|
||||
}
|
||||
else
|
||||
{
|
||||
firstResult = "Open current directory";
|
||||
}
|
||||
|
||||
return new Result
|
||||
{
|
||||
Title = firstResult,
|
||||
SubTitle = $"Use > to search files and subfolders within {folderName}, " +
|
||||
$"* to search for file extensions in {folderName} or both >* to combine the search",
|
||||
IcoPath = search,
|
||||
IcoPath = path,
|
||||
Score = 500,
|
||||
Action = c =>
|
||||
{
|
||||
FilesFolders.OpenPath(search);
|
||||
FilesFolders.OpenPath(path);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
|
|
@ -44,9 +44,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
querySearch = EnvironmentVariables.TranslateEnvironmentVariablePath(querySearch);
|
||||
}
|
||||
|
||||
if (FilesFolders.IsLocationPathString(querySearch))
|
||||
{
|
||||
return TopLevelFolderSearchBehaviour(WindowsIndexTopLevelFolderSearch,
|
||||
var results = new List<Result>();
|
||||
|
||||
var currentFolderResult = CreateOpenCurrentFolderResult(FilesFolders.LocationExists, querySearch);
|
||||
|
||||
if (currentFolderResult == null)
|
||||
return new List<Result>();
|
||||
|
||||
results.Add(currentFolderResult);
|
||||
DirectoryInfoClassSearch,
|
||||
WindowsIndexExists,
|
||||
query,
|
||||
|
|
@ -102,5 +107,28 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
{
|
||||
return _indexSearch.PathIsIndexed(path);
|
||||
}
|
||||
|
||||
private Result CreateOpenCurrentFolderResult(Func<string, bool> locationExists, string querySearchString)
|
||||
{
|
||||
if (locationExists(querySearchString))
|
||||
return ResultManager.CreateOpenCurrentFolderResult(querySearchString, false);
|
||||
|
||||
var partialPath = "";
|
||||
int index = querySearchString.LastIndexOf('\\');
|
||||
if (index > 0 && index < (querySearchString.Length - 1))
|
||||
{
|
||||
partialPath = querySearchString.Substring(0, index + 1);
|
||||
if (!locationExists(partialPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return ResultManager.CreateOpenCurrentFolderResult(partialPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue