Merge pull request #1620 from Flow-Launcher/fix_dup_results_explorer

[Dev] Fix duplicate Quick Access results from CreateOpenCurrentFolderResult
This commit is contained in:
Jeremy Wu 2022-12-12 17:43:41 +11:00 committed by GitHub
commit d2d1c47b92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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

@ -167,7 +167,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal static Result CreateOpenCurrentFolderResult(string path, string actionKeyword, 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();
@ -185,19 +189,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, actionKeyword),
IcoPath = path,
AutoCompleteText = GetPathWithActionKeyword(folderPath, ResultType.Folder, actionKeyword),
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
}
};