From 090dfb39c7b29ec6d5987d382b65819b1475110e Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Fri, 17 Jun 2022 17:14:17 +0200 Subject: [PATCH] Avoid duplicate quick access entry (fixes #152) When you have used quick access previously, the dialog adds matching entries from "previous" at the top. Afterwards the same entries may appear from their "normal" provider (e.q. views, commands, ...). Since the logic of adding entries seems quite complex, this change fixes the duplicate entry by detecting the exact situation (same single entry in first and second provider list), and then removes the duplicate entry list. --- .../ui/internal/quickaccess/QuickAccessContents.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java index f9f72e807b7..65e63113a8b 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java @@ -530,6 +530,14 @@ public IStatus runInUIThread(IProgressMonitor monitor) { QuickAccessEntry.MATCH_PERFECT))); } res.addAll(entriesPerProvider.values()); + + // if one category provides the same single entry like "previous", we can avoid + // showing the duplicate second list + if (res.size() >= 2 && res.get(0).size() == 1 && res.get(1).size() == 1 + && (res.get(0).get(0).element.equals(res.get(1).get(0).element))) { + res.remove(1); + } + return (List[]) res.toArray(new List[res.size()]); }