From 3b8e7866ac92fca5af5448f27da369d6d1c38c0f Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 12 Dec 2022 13:14:21 +1100 Subject: [PATCH] fix duplicate Quick Access results from CreateOpenCurrentFolderResult --- .../Flow.Launcher.Plugin.Explorer/ContextMenu.cs | 2 +- .../Search/ResultManager.cs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index 1a6159073..a6441b5e7 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -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 { diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 4ddc75cfe..ccb550d21 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -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 } };