fix CreateOpenCurrentFolderResult incorrectly using foldername

This commit is contained in:
Jeremy Wu 2020-06-01 14:11:51 +10:00
parent f2690ebfe2
commit cc3d7d7ded
2 changed files with 23 additions and 25 deletions

View file

@ -45,44 +45,44 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}; };
} }
internal static Result CreateOpenCurrentFolderResult(string path, bool isPreviousDirectoryLevel, bool windowsIndexed = false) internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
{ {
var folderName = path; var folderName = "";
if (folderName.EndsWith(":\\")) var title = "Open current directory";
var previousDirectoryPath = FilesFolders.GetPreviousLevelDirectoryIfPathIncomplete(path);
if (previousDirectoryPath != path)
{ {
var driveLetter = folderName.Substring(0, 1).ToUpper(); if (previousDirectoryPath.EndsWith(":\\"))
folderName = driveLetter + " drive"; {
} var driveLetter = path.Substring(0, 1).ToUpper();
else folderName = driveLetter + " drive";
{ }
folderName = folderName.TrimEnd(Constants.DirectorySeperator).Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); else
{
folderName = previousDirectoryPath.TrimEnd(Constants.DirectorySeperator).Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last();
}
title = "Open " + folderName;
} }
var firstResult = ""; var fullPath = previousDirectoryPath != path ? previousDirectoryPath : path;
if (isPreviousDirectoryLevel)
{
firstResult = "Open " + folderName;
}
else
{
firstResult = "Open current directory";
}
return new Result return new Result
{ {
Title = firstResult, Title = title,
SubTitle = $"Use > to search files and subfolders within {folderName}, " + SubTitle = $"Use > to search files and subfolders within {folderName}, " +
$"* to search for file extensions in {folderName} or both >* to combine the search", $"* to search for file extensions in {folderName} or both >* to combine the search",
IcoPath = path, IcoPath = fullPath,
Score = 500, Score = 500,
Action = c => Action = c =>
{ {
FilesFolders.OpenPath(path); FilesFolders.OpenPath(path);
return true; return true;
}, },
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = folderName, ShowIndexState = true, WindowsIndexed = windowsIndexed } ContextData = new SearchResult { Type = ResultType.Folder, FullPath = fullPath, ShowIndexState = true, WindowsIndexed = windowsIndexed }
}; };
} }

View file

@ -55,9 +55,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
var indexExists = _indexSearch.PathIsIndexed(locationPath); var indexExists = _indexSearch.PathIsIndexed(locationPath);
results.Add(ResultManager.CreateOpenCurrentFolderResult(FilesFolders.GetPreviousLevelDirectoryIfPathIncomplete(locationPath), results.Add(ResultManager.CreateOpenCurrentFolderResult(locationPath, indexExists));
true,
indexExists));
results.AddRange(TopLevelFolderSearchBehaviour(WindowsIndexTopLevelFolderSearch, results.AddRange(TopLevelFolderSearchBehaviour(WindowsIndexTopLevelFolderSearch,
DirectoryInfoClassSearch, DirectoryInfoClassSearch,