mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
fix CreateOpenCurrentFolderResult's opening path and text display
This commit is contained in:
parent
cc3d7d7ded
commit
dcca88d746
1 changed files with 21 additions and 22 deletions
|
|
@ -47,42 +47,41 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
|
||||
internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
|
||||
{
|
||||
var folderName = "";
|
||||
var retrievedDirectoryPath = FilesFolders.GetPreviousLevelDirectoryIfPathIncomplete(path);
|
||||
|
||||
var folderName = retrievedDirectoryPath.TrimEnd(Constants.DirectorySeperator).Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last();
|
||||
|
||||
if (retrievedDirectoryPath.EndsWith(":\\"))
|
||||
{
|
||||
var driveLetter = path.Substring(0, 1).ToUpper();
|
||||
folderName = driveLetter + " drive";
|
||||
}
|
||||
|
||||
var title = "Open current directory";
|
||||
|
||||
var previousDirectoryPath = FilesFolders.GetPreviousLevelDirectoryIfPathIncomplete(path);
|
||||
|
||||
if (previousDirectoryPath != path)
|
||||
{
|
||||
if (previousDirectoryPath.EndsWith(":\\"))
|
||||
{
|
||||
var driveLetter = path.Substring(0, 1).ToUpper();
|
||||
folderName = driveLetter + " drive";
|
||||
}
|
||||
else
|
||||
{
|
||||
folderName = previousDirectoryPath.TrimEnd(Constants.DirectorySeperator).Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last();
|
||||
}
|
||||
|
||||
if (retrievedDirectoryPath != path)
|
||||
title = "Open " + folderName;
|
||||
}
|
||||
|
||||
var fullPath = previousDirectoryPath != path ? previousDirectoryPath : path;
|
||||
|
||||
var subtitleFolderName = folderName;
|
||||
|
||||
// ie. max characters can be displayed without subtitle cutting off: "Program Files (x86)"
|
||||
if (folderName.Length > 19)
|
||||
subtitleFolderName = "directory";
|
||||
|
||||
return new Result
|
||||
{
|
||||
Title = title,
|
||||
SubTitle = $"Use > to search files and subfolders within {folderName}, " +
|
||||
$"* to search for file extensions in {folderName} or both >* to combine the search",
|
||||
IcoPath = fullPath,
|
||||
SubTitle = $"Use > to search within {subtitleFolderName}, " +
|
||||
$"* to search for file extensions or >* to combine both searches.",
|
||||
IcoPath = retrievedDirectoryPath,
|
||||
Score = 500,
|
||||
Action = c =>
|
||||
{
|
||||
FilesFolders.OpenPath(path);
|
||||
FilesFolders.OpenPath(retrievedDirectoryPath);
|
||||
return true;
|
||||
},
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = fullPath, ShowIndexState = true, WindowsIndexed = windowsIndexed }
|
||||
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = retrievedDirectoryPath, ShowIndexState = true, WindowsIndexed = windowsIndexed }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue