fix duplicate Quick Access results from CreateOpenCurrentFolderResult

This commit is contained in:
Jeremy Wu 2022-12-12 13:14:21 +11:00
parent ef04819200
commit 3b8e7866ac
2 changed files with 11 additions and 7 deletions

View file

@ -57,7 +57,7 @@ namespace Flow.Launcher.Plugin.Explorer
var icoPath = (record.Type == ResultType.File) ? Constants.FileImagePath : Constants.FolderImagePath;
var fileOrFolder = (record.Type == ResultType.File) ? "file" : "folder";
if (Settings.QuickAccessLinks.All(x => x.Path != record.FullPath))
if (Settings.QuickAccessLinks.All(x => !x.Path.Equals(record.FullPath, StringComparison.OrdinalIgnoreCase)))
{
contextMenus.Add(new Result
{

View file

@ -168,7 +168,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
{
var folderName = path.TrimEnd(Constants.DirectorySeperator).Split(new[]
// Path passed from PathSearchAsync ends with Constants.DirectorySeperator ('\'), need to remove the seperator
// so it's consistent with folder results returned by index search which does not end with one
var folderPath = path.TrimEnd(Constants.DirectorySeperator);
var folderName = folderPath.TrimEnd(Constants.DirectorySeperator).Split(new[]
{
Path.DirectorySeparatorChar
}, StringSplitOptions.None).Last();
@ -186,19 +190,19 @@ 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(path, ResultType.Folder),
IcoPath = path,
AutoCompleteText = GetPathWithActionKeyword(folderPath, ResultType.Folder),
IcoPath = folderPath,
Score = 500,
CopyText = path,
CopyText = folderPath,
Action = _ =>
{
Context.API.OpenDirectory(path);
Context.API.OpenDirectory(folderPath);
return true;
},
ContextData = new SearchResult
{
Type = ResultType.Folder,
FullPath = path,
FullPath = folderPath,
WindowsIndexed = windowsIndexed
}
};