Skip to content

Commit

Permalink
Avoid duplicate quick access entry (fixes #152)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bananeweizen committed Jun 17, 2022
1 parent 22c3963 commit 4716ed2
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,16 @@ private void refreshTable(QuickAccessElement perfectMatch, List<QuickAccessEntry
if (table.getItemCount() > entries.length && table.getItemCount() - entries.length > 20) {
table.removeAll();
}
int count = 0;
for (List<QuickAccessEntry> list : entries) {
System.out.println("---"); //$NON-NLS-1$
for (QuickAccessEntry entry : list) {
System.out.println(entry.getLabel());
}
if (count++ >= 2) {
break;
}
}
TableItem[] items = table.getItems();
int selectionIndex = -1;
int index = 0;
Expand Down Expand Up @@ -530,6 +540,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<QuickAccessEntry>[]) res.toArray(new List<?>[res.size()]);
}

Expand Down

0 comments on commit 4716ed2

Please sign in to comment.