diff options
author | Stefan Lay | 2011-09-07 20:12:21 +0000 |
---|---|---|
committer | Matthias Sohn | 2011-09-07 20:12:21 +0000 |
commit | cc8eb2ef4123391551e350bd3f8893d3aa9cc8e9 (patch) | |
tree | 351e940feb273922a02958613cbfde0ce2a05bb0 | |
parent | 15b2f205724621b61da7c687caa492d706122228 (diff) | |
download | egit-cc8eb2ef4123391551e350bd3f8893d3aa9cc8e9.tar.gz egit-cc8eb2ef4123391551e350bd3f8893d3aa9cc8e9.tar.xz egit-cc8eb2ef4123391551e350bd3f8893d3aa9cc8e9.zip |
Fix list of branches in Switch To... menu
There were two issues which are fixed with this commit:
- The currently checked out branch was not correctly disabled in the
list of the not recently used local branches.
- If no branch was extracted from the reflog also no list of not
recently used local branches was shown.
Change-Id: Ic35d6af2db9f69abf8db278f6d5639b597827b1e
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java index 0a23efb0aa..addb657420 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SwitchToMenu.java @@ -153,13 +153,17 @@ public class SwitchToMenu extends ContributionItem implements localBranches.remove(shortName); } - if (itemCount < MAX_NUM_MENU_ENTRIES && itemCount > 0 && sortedRefs.size() > 0) { + if (itemCount < MAX_NUM_MENU_ENTRIES) { + // A separator between recently used branches and local branches is + // nice but only if we have both recently used branches and other + // local branches + if (itemCount > 0 && localBranches.size() > 0) + new MenuItem(menu, SWT.SEPARATOR); + // Now add more other branches if we have only a few branch switches // Sort the remaining local branches sortedRefs.clear(); sortedRefs.putAll(localBranches); - // A separator between recently used branches and other branches is nice - new MenuItem(menu, SWT.SEPARATOR); for (final Entry<String, Ref> entry : sortedRefs.entrySet()) { itemCount++; // protect ourselves against a huge sub-menu @@ -167,10 +171,10 @@ public class SwitchToMenu extends ContributionItem implements break; final String fullName = entry.getValue().getName(); final String shortName = entry.getKey(); - createMenuItem(menu, repository, fullName, shortName, shortName); + createMenuItem(menu, repository, currentBranch, fullName, shortName); } } - if (localBranches.size() > 0) + if (itemCount > 0) new MenuItem(menu, SWT.SEPARATOR); MenuItem others = new MenuItem(menu, SWT.PUSH); others.setText(UIText.SwitchToMenu_OtherMenuLabel); |